Live data from Hacker News

Ask HN: How do I become a faster programmer?

news.ycombinator.com

41–50 of 71 posts

Re: Ask HN: How do I become a faster programmer?

#41
Get more sleep, eat better, and work fewer hours.

I wrote a more object-level detailed answer about tools and getting better at common tasks, but those are just side issues.

If you're tired, you will fuck things up. Fucking things up is much slower than doing it right the first time.

Similar reasoning for eating well. I'd also recommend intermittent fasting - the kind of biological effects that digesting food causes aren't good for thinking well. Plus, breaking for lunch in an interruption, and not eating lunch is a good way to side-step that.

Working fewer hours is the easiest way to get faster. Pretty much everyone gets slower at programming later in the day. If you simply don't try to force yourself through your least productive hours, you're going to be faster on average.

Re: Ask HN: How do I become a faster programmer?

#42
All else being equal, the fastest code to write is the shortest, simplest code. By being physically shorter there are fewer keypresses (although actually pressing the keys is something I do for a very small percentage of the time spent), and by being simple you will find it much easier to keep track of what's going on where, and you will spend less of your cognition keeping track of it all and can spend more solving the actual problems.

This will often involve moving your fingers away from the keyboard and forcing yourself not to type anything until you have adequately solved the problem, be it inside your head or on a sheet of paper or whatever helps you think. Some people do find that tapping out some code helps them think, but be very careful; if it's part of your pre-coding problem-solving, do not allow your initial problem-thinking code to mutate into your actual code beyond the fact that both of them exhibit a solution to the problem. The odds of your first draft, pre-coding solution-exploring code being the best structure and layout and style and so on, are so slim.

The fastest code I write to solve tricky problems tends to involve an hour or more of thought and drawing and tinkering and examining the existing code and tracing values and running the debugger, and finally a few minutes of typing. Sometimes, if I'm very lucky, I simply delete a line or two of existing code at the end of a half-day's examination and thinking. I then sit back and have a minor fit of hysteria at what would have happened if I had tried to solve that problem by typing first.

Re: Ask HN: How do I become a faster programmer?

#43
There's a lot of advice here that says do this thing, or that. In my experience of almost 30 years, you never become faster. Sure, the bread-and-butter stuff like CRUD you get quick at. Not because you know your IDE backwards, or because tests, or lean - but because you've done it before. Any speed improvements (and quality) come from having done it many times before. And even that isn't a guarantee. Because as you grow, your ambition grows. CRUD that has a list and three buttons (add, edit, delete) morphs into something that does multiple-select/delete, tracks changes, indexes a search catalogue, lets you import and export the list, manage the list remotely, and finally manage a remote list in a disconnected environment.

You'll find yourself wondering why it still takes you four weeks to do a CRUD app, when you have all this experience, herds of war wounds and god-like reputation. It's the best thing about software. There's always a better way to discover, a new trick to learn from a green 20-year-old with 6 months' experience... It's humbling, it's awesome and its tons of fun.

One more thing - people are amazed at my speed and quality. Only because I have so much code lying around by now that I can repurpose in hours, rather than write from scratch in weeks. I spend my weeks doing the interesting stuff. The other big thing experience gives you is the ability to recognise a solution or approach to a problem in an instant, and knowing that given available time, people and skills that it's the right approach.

Re: Ask HN: How do I become a faster programmer?

#44
I believe your asking yourself the wrong question. It should be how do I write better code ? Being faster (on the long term) can only be a side effect of resolving this part first...

How ? By deepening techniques :

- familiarity with the language - knowledge of good architecture (SOLID if your in OOP) - knowledge of the domain you're tackling with - balancing abstraction with implementation according to the weight of a problem - not overtesting

Yeah becoming faster takes time...

Re: Ask HN: How do I become a faster programmer?

#45
Other than what is already covered, somethings that I want every beginner to know:

- Writing some comments (somewhat pseudo code) before writing the actual code within the code file is useful.

- Do not get obsessed with writing working code at the first try. This happens a lot to beginners. They write one (or half) a statement of code, save the file, and build/refresh to see if it is working, then repeat. Please do not do this. Write code, and you can debug/fix typos later. It also builds up your confidence.

- Not reading the errors in the console is a big big big mistake. Please read the console/error-log/whatever, instead of plainly looking at the code dumbfound, thinking wtf is wrong with it. (This does not make you write code faster, but in debugging faster).

Good luck ;)

Re: Ask HN: How do I become a faster programmer?

#46

If you want to write code faster - I have 3 letters for you - I D E. Learn your IDE, be it vim, textmate, IntelliJ or emacs. I used to use textmate (w/ default plugins) for HTML, CSS, Javascript and Ruby. Now I discovered IntelliJ does stuff really fast and works. IDEs/Editors have macros help you perform repeating work fast. TextMate allows you to run shell commands inside the editor which is pretty useful. There ar…

I would also add: get to know your debugging tools really well. I'm constantly surprised how many developers still use print logging to debug issues with data structures. Sometimes it's hard to visualize what's going on in your mind or with the code, why not let the computer "play computer" and actually see what it's doing step by step.

We may not have the real time integration that Bret Victor demos, but a call stack, watch list and breakpoints are a beautiful thing when you know how to use them.

A REPL like Ruby's pry is also invaluable for exploring return data and playing with data access syntax right in the console without long tedious trial by error sessions. (I know this annoys the purists who think you should know the data structures beforehand -- they are right; if you know what you are doing, of course you'll be fast -- but sometimes even the smartest of us don't know a service api changed without popping the hood.

Use all the tools you can to understand what your code is really doing, not just what you think it's doing.

Re: Ask HN: How do I become a faster programmer?

#47
I've noted that the utter lack of criticism towards your own work makes programmers significantly faster.

On a more serious note:

1. Vast and precise knowledge of algorithms and math: to avoid losing time reinventing the wheel.

2. Unit testing: to avoid losing time on obscure bugs.

3. Prototyping: to avoid losing time trying to devise the optimal architecture beforehand and on inefficient refactoring of the system when it is already complex.

4. Rational use of available frameworks and libraries.

Re: Ask HN: How do I become a faster programmer?

#48
You are not a 1960's typist.

Lots of replies here will tell you to practice typing, or learn your IDE etc. That's all tactical stuff but I think biggest gains come from not writing the wrong code to start with. Understand the user; understand their problem, the real problem; and actually solve it

Re: Ask HN: How do I become a faster programmer?

#49

Get more sleep, eat better, and work fewer hours. I wrote a more object-level detailed answer about tools and getting better at common tasks, but those are just side issues. If you're tired, you will fuck things up. Fucking things up is much slower than doing it right the first time. Similar reasoning for eating well. I'd also recommend intermittent fasting - the kind of biological effects that digesting food causes…

I completely agree with that! I know so many people coding ridiculous hours, and all they do is causing more problems the next day. Less hours = Better focus

Plan your food and sleep. Probably exercise. Get a fitbit (or similar) and find your sweet spot (sleep tracking is awesome with those things). When you feel good- you're most effective.

If you're having deadlines, take long breaks and go back to work after you've done something different (essentially shift working but within reasonable hours).

Don't "overdose" yourself with energy drinks, or too much coffee/tea. I have found that some energy drinks do affect my ability to focus negative. Same with coffee- too much is limiting (my) ability to focus.

All those things helped me. It can be different for you, but it's probably a start.

Re: Ask HN: How do I become a faster programmer?

#50

Other than what is already covered, somethings that I want every beginner to know: - Writing some comments (somewhat pseudo code) before writing the actual code within the code file is useful. - Do not get obsessed with writing working code at the first try. This happens a lot to beginners. They write one (or half) a statement of code, save the file, and build/refresh to see if it is working, then repeat. Please do n…

Also this!

One of the things that makes me fast is something that was a premise that was very slow to start with: "every error means something, no error is random, once you understand the error completely, you usually also understand the problem."

Almost every time I have ignored an error without understanding it, it has come back to bite me a hundred ways until I finally get it. It seems faster to ignore the details and plow on, but those hundred missteps add up vs one sure step, so practice reading those errors and understanding exactly what they mean. When you know that you can choose to ignore them, but it's likely it will be faster to simply fix the problem.

Post reply on HN