
Ask HN: How do I code faster - avaid1996
I&#x27;d love to be more efficient with my time. Would appreciate any tips like focus tips, editor tricks, etc.
======
FroshKiller
In my experience, long-term efficiency comes from spending less time writing
code and more time thinking about it thoroughly first. I slow myself down by
writing notes and questions in longhand. Then, after I've done that and
written the code, I spend a little more time focused on making my output
maintainable and reusable.

That might not be the kind of answer you wanted or expected, but believe me,
taking it slow and working for the future will net the most efficiency in the
long term.

------
chrisbennet
As others have mentioned, "coding faster" implies writing more code quicker
when what you actually want to do is _write less code_.

The way to write less code is to (a) better understand the problem and (b)
have a mental toolbox full of good tools you can apply in different
situations.

For (a) you need to delay coding - which admittedly _really hard_ until you
have a good picture of how you want things to work. For me, when I'm in front
of the computer, I don't think as deeply as when I'm away from the computer.
Many of my aha! moments come when there are no distraction like when I'm in
the shower laying in bed before I get up.

(b) Is just study, curiosity and research.

------
onion2k
Put effort in to learning your tools. The number of people who haven't even
read the documentation for their preferred IDE is incredible; we use _really_
powerful tools every day, so make the most of them. Customise them. Make them
work for you.

------
smt88
Extensive static analysis (language with strict type system + linter + hinter)
and functional programming have revolutionized my productivity. It helped me
write a large program which has been in production for 11 months and has had
zero bugs.

~~~
kenshi
Would love to hear some concrete details about this - I dont doubt you, but I
think it would be helpful to have the details.

Would you say you were able to write less code (perhaps reuse more code)? Were
the productivity savings mostly on the fact maintenance costs are lower?

~~~
smt88
I don't think about "less code" when I'm writing code. You write something
(ideally) once, and you read it many times. It's very inefficient to optimize
for code-writing when the most expensive activities are learning, re-learning,
and maintaining code. If your code is twice as long but easier to understand,
you should just make it twice as long.

As far as more code reuse, the tools I mentioned don't affect that. A good
rule of thumb is not to write the same code twice. If you write it a third
time, move it into a reusable function. I actually rarely write the same code
even twice.

So yes, most of the savings come from 1) not having to debug and 2) not doing
maintenance until I want the code's behavior to change. With great static
analysis and a type system, you might spend 5x more time writing before you
run your code the first time, but it always _just works_ when you do run it
the first time. It's amazing.

This is a famous talk by Rich Hickey that will discuss some of these issues
much better than I can:

[https://www.infoq.com/presentations/Simple-Made-
Easy](https://www.infoq.com/presentations/Simple-Made-Easy)

(Video on the left)

~~~
kenshi
Thank you for taking the time to respond and the link.

------
bjourne
You do it by slooooowing doooown and focusing on the details. Fast and sloppy
is __NOT __the way to go. It might seem counter-intuitive but that is the
_only_ way to gain speed.

