You have to be exposed to code written by other people in order to see better ways to do things.
Ask HN: How do you get better at coding?
41–50 of 73 posts
Re: Ask HN: How do you get better at coding?
#42I 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, somet…
Re: Ask HN: How do you get better at coding?
#43Re: Ask HN: How do you get better at coding?
#44Re: Ask HN: How do you get better at coding?
#45Re: Ask HN: How do you get better at coding?
#46Instead just learn how to solve your actual problems or entertain yourself using programming /today/. Making your friends websites, making games for / with your kids, making an app to water your plants, making spreadsheets to manage your finances, automating that annoying manual thing you do at work, making goofy software that converts images to pixel art, whatever floats your boat.
You have to make a lot of bad things to start making good things. So start making bad things, and enjoy it while you're at it - I've made my fair share.
Do a little bit of programming every day. Do it for now, and not for later. Set yourself a direction every so often, but not much more than that. Review your own work and see what was not great, and figure out what to learn next to make it better. Show your work to other people and ask them for help, or enjoy together. It's much more pleasant to look back later and continually be surprised how far you've come.
Re: Ask HN: How do you get better at coding?
#47For example, if you want to write an SQL parser/analyzer, take a stab at how you'll structure it, then try extracting this piece from postgresql. Compare and contrast. You'll learn how a good modular code looks like and start learning how to apply such patterns to your code.
Delving into a code base without a goal isn't helpful imo. You need to have a main goal like fixing a bug, adding a feature, or extracting a piece to integrate it into your own code.
Re: Ask HN: How do you get better at coding?
#48Reading, esp. code (including learning new languages and reading in them), shows me new paradigms, new idioms, new ideas, sometimes parts of new ideas which may click together later. Sometimes the patterns may however be subtle and not easy to notice by pure code reading; in such cases reading free-form prose (blogs/etc.) can help notice them. Also reading code invariably provides examples of bad code, to be remembered as a warning and something to try to avoid.
Writing code introduces need for actually choosing some of the learned approaches, excercises the learned theory, ingrains it, shows the shortcomings and costs of particular patterns/approaches, their nuances, where they fit and where they don't, allows to experiment with them.
"Exchange with coworkers" is usually also reading in my case, i.e. code reviews.
And I just realized that also doing code reviews helps me improve coding in one more way: I sometimes discover stuff when I'm trying to express in words why I find some peer's code jarring, troublesome, or confusing.
Re: Ask HN: How do you get better at coding?
#49Re: Ask HN: How do you get better at coding?
#50Edit: and to answer your question. At first I learned by reading other's people code and trying stuff. Adapting existing base bit by bit can go a long way. Back then I had no internet.
At university most of the curriculum was theoretical. We have done very little actual coding and most problems were too small. Often too specific and vague at the same time.
Nowadays I learn by coding. When you re-read your code from a few months back it should look bad, this is the sign that you have progressed. If there are no idiomatic ways of solving a particular problem, I try to find a better way to implement it each new time.
Finally, I try to talk to people smarter or more experienced than me.
If I would change one thing, it would be to do more projects in university and make them follow agile methodology with the teacher as product owner.