Live data from Hacker News

Ask HN: How do I become a faster programmer?

news.ycombinator.com

51–60 of 71 posts

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

#51

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…

Morning people tend to get slower later in the day. Night people actually tend to get faster.

(There is some research that backs this up: http://www.personal.psu.edu/afr3/blogs/siowfa12/2012/09/earl...)

Know yourself and work during your peak time, not someone else's.

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

#52
You can't solve individual problems faster(unless they're familiar problems, which doesn't make you an "overall better" programmer, just better in that problem domain). Every programmer tends to fall within a certain range of time-to-solutions when they encounter a novel problem for the first time. Innate ability is, in the end, not something worth worrying about because it's also not a "universal", it applies to particular problems just like domain knowledge. What you can do is create a workflow where you have fewer incidental problems, and so you end up being faster and more accurate in your coding all the time because you just don't run into trouble.

1. Can you write less code? Not just code-golfing, although that is worth experimenting with(see Arthur Whitney's code. Make an honest attempt to "get it" without just giving up). You'll have to develop your own metric, but some combination of - lines of code, new names declared, branch points, nesting, subroutine length, etc. can usually tell you if you're progressing.

2. Can you use fewer language features? There is an ingrained tendency in many programmers to jump onto everything new in fear of being left behind, and then use all of it at once on a project where it's wholly inappropriate, becoming "that guy" who constantly reveals compiler bugs. But the features that last over multiple generations are the key: People shipped good software with it before, and they'll do so again, so if you stick to a conservative subset and roll your own abstractions otherwise, you can use familiar techniques everywhere, but enjoy an incrementally smoother experience with the newer environments. (Of course, at the extreme end you also become "that guy" who is coding everything like it's the 1960's, but at least that means that you are probably productive in some way, if not really up to speed.)

3. Although I dismissed familiarity in specific problem domains above, diversity of experience with specific problems is better for your overall abilities, because the natural grain of problems exposes different styles of coding.

4. Do you know your tools? Not just "I can use my text editor and compiler," but rather, have you tried to deeply evaluate all the technology available? If you can use a simpler toolset, that's usually better, because something simpler is easier to extend or replace. Something that is deep and intricate and complicated is bad, because it becomes an edifice. True of the code you write, of your coding environment's configuration, and of the tools you work with, be it editing, builds, source control, etc. If you rely on a debugger for everything, then you're at a disadvantage when you don't have it. So you have to adapt to the situation.

5. Do you put the data first? This is the flip side of the "edifice" remark - your code never lasts, but your data does, and, less frequently but perhaps even more importantly, protocols and formats you invent for passing around data also last. If you're taking good care of the data, everything else become possible. But if you tangle it up in a way that makes it hard to work with, everyone gives up.

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

#55
post #22

It is just like optimizing any piece of code. Log everything, identify hotspots and improve them. 1) Time yourself. Keep a little text file with timestamps and brief fragments of what is going on. Do this every time you have a mental context switch, start a new sub-goal, accomplish something or give up on an attempt. Usually I find myself logging something every 5-15 minutes. 1B) Documentation lookups should not be m…

This is the answer I was looking for. Especially point 1.

Wish I could give multiple upvotes.

Organized optimization!

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

#56

I would say: 1) get rid of distractions 2) stop creating bugs 3) get really good in debugging This sounds a little odd bug getting rid of distractions (set all you favorite websites in /etc/hosts to points to 127.0.0.1) forces you to focus on the problem. Stop creating bugs is impossible, but you can make your best afford to test your code and write good code (read the book "clean code") But I think the biggest speed…

Great point about debugging.

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

#57

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 wh…

I waste alot of time on self criticism.

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

#58
Things like Vim can speed up coding, you spend less time on the actual editing of the text. I used to just use vim (macvim in fact), but for php i recently (1 year?) switched to PhpStorm with a VIM plugin. That was a huge speed increase, being able to cmd+click on method names and be taken to its code and probably about 20-30 other features i use in php storm that i never had in macvim (even with a whole bunch of vim plugins).

(the vim plugin in phpstorm isn't perfect, but definitely good enough)

But I find the biggest speed ups are things like:

- using frameworks (and knowing about them - so you know everything the framework contains/can do) speeds a lot of things up. It helps to know a framework inside out as well as a majority of the popular libraries that are used with it.

- And knowing what libraries exist to do whatever job you are trying to do can save a lot of time. I think almost everyone has at one point coded something then later on found a perfect library (or even 'snippet') that they could use and would have saved a lot of time. As long as the library is mature enough I'd always prefer to include a library and use that rather than spend hours/a day/days/longer on coding something from scratch. It also helps if something stops working - you can probably find someone with experience with that library. Of course it does come with the disadvantage of it might not 100% fit what you need to do...

But it isn't like coding is a race. You often save a lot of time by going slower and planning things out. I used to plan apps out in a text file, but realised a few years ago that getting away from the computer and planning out everything on paper (lots of sheets of paper, lots of arrows, lots of mess, but in the end it makes sense) gets everything planned correctly before even coding, so there is no need to refactor big sections of your app. I always have a notebook of notes when programming now... even with lots of squiggles and messy handwriting it helps a lot more than notes in text files or even worse notes (like in depth to do notes) in /* comments */ or //comments .

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

#59

By first becoming a slower programmer. I know it sounds very zen-like, but when you give it some thought, you'd discover that most of your time is spent bug fixing. Worse for us embedded guys, as it's really easy to get into the build-download-run cycles and each takes much more time than a typical run cycle on a .NET environment, for example. Just realize that actual coding is the easy part, and concentrate on slowl…

The analogy I like is cornering a race car. The fastest way through a turn is a combination of velocity, distance, and traction. If the speed is too great, the line is too long. If the line is too tight, exit speed is too low.

Or the race car spins out.

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

#60

By first becoming a slower programmer. I know it sounds very zen-like, but when you give it some thought, you'd discover that most of your time is spent bug fixing. Worse for us embedded guys, as it's really easy to get into the build-download-run cycles and each takes much more time than a typical run cycle on a .NET environment, for example. Just realize that actual coding is the easy part, and concentrate on slowl…

As a corollary to this, increase the size of your toolkit. The more tools you have available to you, the more likely you are to have a tool which solves the current problem in a way which is correct, clear, and concise. You'll also be better able to determine when to, and when not to, re-invent the wheel.

By toolkit, I mean:

- Programming paradigms

- Patterns (and Anti-Patterns)

- Metaprogramming

- Knowing when to mutate, and when to not mutate

- Algorithms

- Data Theory

- Knowing the value of stepping away from your code

Post reply on HN