Being aware of and managing my ignorance. I don't know if I can describe this very well, and I've only recently started explicitly noticing this about myself, but I seem to have a well-developed intuition of how much I am "in the dark" about a particular domain, problem, technology, library, behavior, etc. I seem to sense well (and can back up with explicit arguments if necessary, but it stars with a feeling) when th…
Ask HN: What habits made you a better programmer?
51–60 of 103 posts
Re: Ask HN: What habits made you a better programmer?
#52This leads to a surprisingly large number of practical habits.
1. I welcome code reviews. Some people can't stand their code being criticized by other people. To me the fact that someone else spends time improving my code is a clear win. Ego is not bruised if you start with assumption of being stupid.
2. I seek out and use tools that help me find bugs automatically and understand my code better. Static code checkers like clang analyzer or cppcheck or pychecker or lint. Valgrind, good memory and cpu profilers, good debuggers. Source Insight (an editor).
3. I see enormous value in continuous build systems and automated testing (be it unit tests or more holistic tests).
4. I step through new code I write in the debugger just to verify that it behaves the way I expect.
5. I stay away from complexity, both self-inflicted (like trying to be too clever when implementing something) or inflicted by the tool (e.g. I avoid using advanced features of C++). I avoid multi-threading as long as I can.
6. I add diagnostics to my code. Logging, asserts in debug builds, built-in crash dump submission to my site for analyzing crashes that happen in the wild.
7. I know that despite doing all I can to prevent it, the bugs will happen and will have to read my own code to fix them long after I wrote that code. Therefore I try to make the code as readable as possible for my future self. Balanced comments (not too much, not too little). No cryptic names for variables or functions. No long functions with complex logic. I take the time to make my code look consistent.
8. It's better if other people sweat writing and fixing bugs in their code than me in mine. I look for high quality, reputable components instead of re-inventing the wheel. I would much rather use SQLite than write my own persistence layer.
Re: Ask HN: What habits made you a better programmer?
#53Re: Ask HN: What habits made you a better programmer?
#54Knowing when to stop. When you reach a seemingly impassable problem, talking it over with other people and then sleeping on it will make everything clearer come morning. If you work constantly you are a worse programmer than those who know to take breaks. These are the people who are thinking about what they're doing.
I certainly don't recommend quitting every time you have a problem you can't solve in half a hour, but there's a happy medium between that and wasting days (while you're getting paid, or at least wasting your project's time) working on something that the guy in the next room could sweep away in ten minutes.
Re: Ask HN: What habits made you a better programmer?
#55Thinking in a functional fashion also made it easy for me to pick up JS and start writing event-driven code almost immediately, because so much of modern JS relies on proper understanding of closures and asynchronous events. Furthermore, if you find you like functional programming, I also highly recommend teaching yourself Church's basic untyped lambda calculus; I found that it helped give me a much better understanding of the basic underpinnings of so many languages. Similarly, having an understanding of the fundamental concepts that underlie all programming languages -- such as the differences between call-by-value and call-by-reference, or static and dynamic scope, or the various kinds of OO systems (prototype-based, class-based, mixins) -- is really important. My knowledge of these has not only made it really easy for me to pick up and learn a language extremely quickly, but has also saved me on more than one occasion from a pitfall that I would have otherwise made (such as forgetting that older versions of Perl use dynamic scope by default).
Also, as many other people here have mentioned, coding up solutions to problems from ACM competitions, Project Euler, Google Code Jam, etc. is a great way to get good at just coding. It is also a great way to familiarize yourself with a language.
Re: Ask HN: What habits made you a better programmer?
#56Re: Ask HN: What habits made you a better programmer?
#57Being aware of and managing my ignorance. I don't know if I can describe this very well, and I've only recently started explicitly noticing this about myself, but I seem to have a well-developed intuition of how much I am "in the dark" about a particular domain, problem, technology, library, behavior, etc. I seem to sense well (and can back up with explicit arguments if necessary, but it stars with a feeling) when th…
Re:Premature optimizations. I believe the great Pele offers something to cure this... it might help you.
:0P
Re: Ask HN: What habits made you a better programmer?
#58I became a better programmer by writing a lot of programs.
Refactoring your code, or possibly coming up with an entirely different approach to solving the problem is what I consider one the most important parts of becoming a better programmer.
Re: Ask HN: What habits made you a better programmer?
#59Keep notes - I use blogger.com
Write documentation - writing man pages has forced me to fix corner cases
Having projects with real users - they are annoyingly good at finding errors
Turn on -wall, keep coding until you get none
Often the best place to solve the problem is AFK.
Healthy body, healthy mind - combined with the above I like to bicycle, an hour in the pedals pays you back. Cooking proper food yourself from real ingredients feeds your brain.
TMTOWTDI - dabble in languages you don't use as your main such as Forth / Scheme / Assembler / J / Factor / Brainfuck