Ask HN: How do you get better at coding?

60 points by kilianso ↗ HN
I'm trying to get insights from developers for a school project on how they get better at coding.

The survey below contains just 6 simple questions to answer. Or just answer here. THANK YOU!

https://goo.gl/forms/emc16fdMC8UkTYYh1

72 comments

[ 2.7 ms ] story [ 128 ms ] thread
1. Practice. 2. Read good open source code, design patterns, understand and apply. 3. Repeat.
By coding and reading other people's code.
> reading other people's code

+1 for reading other people's code. I'll build on that by adding:

- by learning to make your own code readable

- by working with people who want to make code reviews a priority

1. Choose a project I don't have a clue how to do but I also find interesting

2. Dive in head first knowing a ton of research will need to happen

3.

4. Profit

I write code on personal projects every day. Sometimes when time is an issue it's just a single line bug fix or an update to some documentation, but regardless I get a little green square on my Github graph every day. It has two important effects. Firstly, it means I have to keep coming up with new things to write code for to stop it getting boring, so I explore a new things a lot. Secondly, it's made me think about how I can stop wasting time when I code, and how I can use my tools better. I've been doing it for about 200 days now, and I've definitely improved already (this is after being a developer for 20 years so far).
1. Read Books/Online

2. Use Anki for difficult memorization

3. Use mindmaps for difficult concepts

4. Practice Coding

5. Sleep and Exercise for mental health

I've also found a low carb high fat diet helps me focus a lot more ymmv .

(comment deleted)
I get better at coding by coding.

No, really. You can read all the books, blog posts, open source code samples you want, but nothing will substitute writing code.

I maintain a handful of side projects as well as write code daily for my job. Plus, I love it. Also, my side projects usually encompass something I have no idea how to do, which quickly elevates my skill level. I love learning, so it works for me.

I think I "read" about programming for something like 15 years (books, blogs, HN, proggit, irc chat)

I started actually coding seriously and properly the past 1-2 years. Easily learned a hundred-fold more by doing it, literally.

I think too often I told myself I'm "not good enough to make something serious". And you know -- it was probably true. But that doesn't matter. Just start, things will fall into place, sometimes you'll fail, sometimes you won't. It's just the only way really.

> I think too often I told myself I'm "not good enough to make something serious". And you know -- it was probably true. But that doesn't matter. Just start, things will fall into place, sometimes you'll fail, sometimes you won't. It's just the only way really.

it's not true, most "serious" things aren't that difficult or complex

(comment deleted)
Do you mind sharing your age? Also, what programming language/s do you code in and what level have you reached? Finally, how did you actually start coding?
(comment deleted)
Code reviews help a lot with that. At my current company we don't review so I've found myself getting complacent
I've found this too - I work much better when I know someone I respect will read my code.
Yes. Being able to give an opinion about code or code design and back it up with reasoned arguments (as opposed to dogmatic obedience) is part of becoming a good dev imo
Agree, I think code review also helps yank out that laziness in that code that we thought we didn't have time to make more readable. Send the code back and make them push their code to a better level before putting it live. I've noticed UX problems in code reviews from people who should know better, we just get lazy and think "working" is good enough.
This sounds right but in reality I think something is missing if you end up isolating what you know and just keep coding. I worked with a guy who programmed for 5 years and wrote the same crappy code he wrote 4 years ago. If you don't know you're doing something wrong because even though you are solving problems the hard way to you you're still solving problems. If you are always pushing yourself and reading you learn there is a better way.
I would add that it's also a iterative process: code, review, learn, and code some more. A continuing process
Yes, not just experience is important, but experimental experience. I learn so much less at work than I do on personal projects simply because I don't experiment as much. Unfortunately the realities of time and effort have caught up with me and I don't get to put nearly as much time into personal projects.
I get even better by coding with others. As I look at their code, as they comment on mine, I learn more than I would simply by working by myself.
This. I have a large directory containing side projects that will never and were never intended to see the light of day; solely built for the learning experience.

Generally speaking, when I discover some interesting technology, I attempt to implement it in whatever language I am currently trying to improve my skills with, regardless if it's not the best environment. A good example of this was implementing the Ethereum VM in PHP. After just a few weeks of tinkering, some takeaways were learning the best and fastest ways to interact with binary data in PHP, improving my mental model of state machines, improving my debugging skills, learning how JIT compilation works, handling "big numbers" properly and caveats between several available libraries, etc...

A few important rules that have proven successful for me:

1. If available, your first iteration should be built purely following a specification (e.g.: RFC, whitepaper, yellowpaper), otherwise, if you have enough domain knowledge and understanding of what the program should actually do, build it without any reference, but allow an exception for researching (when required) very specific problems such as determining the best sorting algorithm for some function. Performing either of these will challenge and improve your ability to carry out the SDLC.

2. Hand-in-hand with #1: Don't start testing against (or even looking at) other reference implementations until at least iteration two. Whichever iteration this lands on, it'll likely be your first major refactor and will be the most time consuming, but most satisfying step. You will discover things you've (supposedly) done right (awesome++), things you've done wrong (learning++), and maybe even novel solutions to problems that end up being noteworthy contributions to the community (really awesome++++).

3. For lack of better phrasing: Focus on the specific task of the program or library. For example if your project is multiplayer netcode, you will of course need a game engine of some sort to capture a realistic state from, feed the data to, display it, etc. Sure, go ahead and write a simple game engine, but as cool as it is, don't focus on that...just get it to do what you need for your netcode! Game engines are cool and so are other subsystems of multiplayer games, but don't get distracted. This example is being used because multiplayer games are complex and meticulous and spending too much time on each subsystem may lead to burn-out or disinterest for what should be a far smaller project.

4. Don't worry (too much) about the language or environment being used. Unless you're planning on the project materializing in to a product, the sole intent should be becoming a better programmer, which requires only one language and a fresh project. Learning a new language isn't going to immediately make you better at programming, although there are plenty of benefits in learning new syntaxes and paradigms. Plus, you may always use your newfound domain knowledge as motivation to pick up the appropriate language and/or platform.

5. Never be intimidated.

This is exactly right. Practice, practice hard and hard practice. Then some more practice. People don't like that answer because they want to get good by watching Youtube videos. It doesn't work.
I believe a large part of getting better at coding is reading about good coding practices and simply reading other developers' code, regardless of its quality. For example when I was in junior college a programmer-on-duty recommended I read Kernighan and Plauger's "Elements of Programming Style." Reading this style guide had an immense impact on me. Following that book, I discovered Kernighan and Plauger's "Software Tools" which illustrated important aspects of the UNIX philosophy (and good design principles) such as "Write programs that do one thing well" and "write programs that work together."
Practice.

1. If I'm learning a new language, I pick a topic I know well and try to apply it in the language. Typically the first pass is nonidomatic, and I iterate as I learn more about the language. 2. If I'm learning a new algorithm, I use a language I know really well. 3. If I'm learning a new framework, I pick a smallish project and dive in.

Most of it is throw away, and I've found that takes a lot of pressure off.

Work for different companies, that use different technologies. Experience is really the best way to learn. Plus you get paid for it!
I apply the 80/20 rule recursively. It’s something I caught myself doing at some point and now I tell junior devs to do the same thing.

If you spent most of a day on something, nobody is going to notice an extra twenty minutes to fix it up a bit more. Especially if it means fewer production issues with that code. On a sane project the interesting problems are given to the most reliable people, not the fastest. So look at th code one more time than you deem necessary.

Try to look at it the way someone else will or the way you will in six months when you touch it again. Do the commit comments match the code? Can you tweak the code a bit to make it mean what you said? Then do it.

Pairing.

Bouncing off ideas, war stories, snippets, learning and sharing alternative ways to solve problems. Priceless.

i take courses on udemy and coursera.
Every Sunday, I go through the things I did that week (including work and social events) and ask "how could that have gone 10% better?" Then I see if I can apply those ideas to future projects.

Years of accumulating minor improvements based on real projects I actually worked on have compounded.

Everyone here is saying by coding. I largely agree. However, there is probably 10% of my time where I talk to others who are way better than me, know about topics I want to learn about and then go learn. A lot of times you can save a bunch of time by getting knowledge from the best vs a random guide online.
1. Eating crow when customers find my bugs.

2. Rewriting, rewriting, rewriting

3. Trying new languages for fun (I ported a LAMP website to Node to learn about node+express)

Spread your knowledge around, read on oop, read on functional programming, learn what google and Facebook do in a situation, learn to get good enough to criticize with confidence. If you can't criticize a situation with confidence then learn more about it.
Definitely agree - IME the best programmers can usually give a long list of informed complaints about their favorite tools, as well as reasonably discussing alternatives.
As everybody else is saying, practice practice practice.

I'll add one extra on top of that: it's important to practice on real, complete, non-trivial programs that actually do something. Ideally it'll be a large project because that will give you practice in working with other people, API design, refactoring, testing, debugging, and reverse-engineering.

See what others are doing wrong, notice what I think and realize that I never want someone to feel like this when reading my code -> IMPROVE.
Be aware of the three paradigms (http://wiki.c2.com/?ThereAreExactlyThreeParadigms). Get proficient in at least one language for each of them. It will get you a host of transferrable knowledge.

Tinker a lot and don't be afraid to make your own mistakes (and learn from them once you've recognized them).

1. Write code for side projects 2. Read others code for similar projects in same language.

On #2, for example, if you are working on a todo list backend in python, try to find existing solutions for todo list backend in python. Then you can see what others using in their solutions and try to bring them into yours.

I understand, this approach is not applicable for everything but I have found lots of gems this way.

Conversely, avoiding looking at what others have done and doing it yourself can help loads too.

Only when you get stuck and cant figure something out with your current knowledge set, should you venture to look at others solutions.

Or after you have completed your solution and are curious about what others have done. You might find a library that makes your life way easier, but had you started out using that library, you wouldn't have the best understanding of the nitty gritty details.

I will admit sometimes I get a little ambitious with what I want to do and end up looking at other solutions to see just how complex we have to go.

1. Write big enough programs of your own such that you experience them collapsing under their own weight. That forces you to see the consequences of your actions. Only then can you really learn how to structure things better.

2. Try to learn the underlying technologies thoroughly. For example, try writing a simple C compiler and linker. That will teach you about a lot of things that a lot of the programming world sits on top of.

I've learned no greater lesson about program structure than the time I finally got around to writing test cases for my first modest (~10k lines of C) personal project.
Learn from your own code, compare other's coding practices.

That worked for me.