Ask HN: How do I become a faster programmer?
I want to be a faster programmer, to increase my coding speed.
How can I do that? Is it even possible?
At the moment I feel like I have no choice but to go at the pace that my mind allows me to operate at.
70 comments
[ 15.1 ms ] story [ 137 ms ] threadDisclaimer: I am not a fast programmer.
So, either get more familiar with the tools, or use simpler, more effective tools, or both.
Having a large and supportive network allows you to quickly overcome obstacles and piggy back off of other people's expertise while developing your own.
Everyone has their own pace, some may just be naturally faster and that is ok. They also might make more mistakes (bugs).
As other posts have mentioned, learning the language and libraries will help you massively.
By solving a problem I mean not just decomposing it mentally but also executing the solution with chosen technical framework.
Practice a lot, pick a framework or two and understand its inner workings very well - that's my advice.
For example, the first time you code a linked list, it's going to take some time to get used to how it works and to program it correctly. The second time, you might still need to look something up. However, once you got used to the abstraction, you can simply type it down as fast as your fingers allow.
This has nothing to do with what your actual goal is but rather it's the process of translating your thoughts to a particular abstraction that you can directly write down in code in a particular framework (the programming language). This abstraction layer varies for different programming languages and you simply need to get used to it and gather experience.
I think of it as trying to speak a foreign language, e.g. English for myself. I'll never get faster than in German at saying what I want to say (albeit, there might be cases where English is way more efficient). The entire process is simply limited by how well I'm able to translate thought into the abstraction layer of speech. As everybody will tell you, this skill is greatly enhanced by actually using the language in various contexts until it becomes intuitive.
Just realize that actual coding is the easy part, and concentrate on slowly and properly designing what you're going to build and reviewing what you just wrote. If I'm building something complicated, I'd take a day, maybe more, just to think about it slowly. You can't rush a thought process. I'd implement it, and I'd review it multiple times before even running it. Makes for the fastest development, unless you're just thoughtlessly hacking on something inconsequential.
But if most of your time is spent debugging, then taking your time is probably worth it. And use tools that makes a lot of bugs impossible: Use a memory-safe language with strong typing and concurrency abstractions that prevent data races etc.
If you're making a big system where remembering where everything is is half the job, a good IDE with solid auto-complete might help. I'm a big fan of MS Visual Studio, though it has limited programming language support. I've heard good things about Intellij too.
If most of the code will be written by someone else then you want an opinionated programming language that enforces a certain style, like Ada or Go.
Finally, if your problem has already been solved, don't solve it again. Use Erlang for distributed systems, Ada for critical systems, Esterel for extra-critical systems that can afford to be slow, etc.
> At the moment I feel like I have no choice but to go at the pace that my mind allows me to operate at.
This is perfectly fine and exactly where you should be. If you force yourself to work through problems faster than what your brain wants you to do, you will make mistakes and spend more time cleaning up after yourself.
Following from that, to be a faster features developer, I have one simple solution: write less code. It's taken me 10 years to understand the wisdom in this but I assure you it's true. You will move faster, you will write better code, and you will stop hating your past self so much.
As much as some people argue against this, software development is a creative process. Creativity takes time. There are times where you are writing rote, boring code, and for that you can speed up with editor tools (IDE stuff as another commentor said) and learning to type faster, but make sure you recognize when you need to slow down, and you'll find yourself becoming much more productive.
Or the race car spins out.
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
By doing this you will also increase your reading speed which also helps increases your programming speed. Your mind is the fastest thing you have, it is the translating of what you are thinking or seeing to typing that slows one down. This is why there has been work on trying to use your brain waves as an output device so you can bypass having to type what you are thinking or reading.
Structure your work and try to develop a strategy. So think about (w)hat, (w)hy, ho(w), (w)here, (w)hen. - What: What is the core problem to solve? - Why: If it is a 'problem', why is it a problem, is there an existing solution? If not, why is the feature important - empathize with the feature request. - How: What is your strategy, how do you want to conquer this task? - Where: Where does the solution has to be implemented to fit best? - When: Programming is a process (a timely and logical sequence of activities which are required), thus define what step has to be done before the next. Example: one should not start with the development of a "user scores database" if the main objective is to build a jump-and-run game.
These steps are helping myself to be more productive.
0. Type code faster
1. Quickly Identify Problem Types
2. Do Algorithm Analysis
3. Master Programming Languages
4. Master the Art of Testing Code
5. Practice and More Practice
Read more about competitive programming free PDF book here. The tips are on Chapter 1.2
http://www.comp.nus.edu.sg/~stevenha/myteaching/competitive_...
Find out which shortcuts would give you the best keystroke / time earned ratio.
2- Sharpen your skills inside out.
Truth is, to be very fast at something, you must have done it many times before. I don't believe one can be fast at problem solving if it's the first time.
Once you get the usual patterns squared, you can get quite fast at implementing them.
3- Write in a more functional fashion
This has a strong tendencies to reduce bugs and that's where massive time wasted can go.
4- Improve your understanding
Often slow speed is due to a lack of full understanding. Draw and redraw a problem on paper until you have a good grasp of the problem. Mix it with other concepts of real life (ie. arrays and stacks of dishes)
I think we were all slow before we were fast. Still there are many devs faster than me. That said, I think creatively faster than them. I think we all have our advantages/disadvantages based on the way that our brain is wired.
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 manually logged. Instead flush your browser history for the day before starting and then save out a copy of that when you are done programming.
2) Once finished, identify and eliminate time sinks. If you spent 15 minutes writing boilerplate, refactor that out for the next time you need it. If you spent 15 minutes looking for correct bit of previously refactored boilerplate, organize your archived code. Look at what parts of the documentation you visited the most and study them.
3) Always be trying new tools. There is no such thing as a silver bullet, but there are some pretty impressive special purpose alloys. While tedious, it is worth running previously-solved challenges though the new tools. (Subtract out the time spent just thinking during the old run to correct for the additional experience on re-running it.)
4) Practice! Find the smallest "unit of delivery" and deliver that as often as possible. For example if you do games, do game jams.
By following these I am now 60x faster for one subset of competitive programming (Mystery Hunt style puzzles).
Wish I could give multiple upvotes.
Organized optimization!
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 are few for Ruby if you want to see output of an execution as a comment (see Avdi's screencasts).
There are shortcuts for performing tasks. In case your IDE does not provide, use the ones which your operating system supports. Example for Mac OS X - you can use Apple Scripts, Alfred, Keyboard Maestro etc.,).
Take time reading your IDE manual or help. Graphical UIs show tips and suggestions. console based provide tutorials when you open without arguments. With vi, use :help and follow the article. It takes months or even years to understand and learn your IDE.
Talking about downsides, once you start using your IDE a lot, you will learn about the downsides like 'pinky finger problem on emacs' (Google for this), and then you'll realize you have to customize your IDE. Note: These are good to have problems because you realize you are advancing.
For HTML, ZenCoding as a plugin came out 3-4 years ago where you can use div.container>div.hello+div.details>span>a*3 (on tab) will expand and give you html.
StackOverflow has lots of answers and details on discovery of productivity tools.
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.
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 are few for Ruby if you want to see output of an execution as a comment (see Avdi's screencasts).
* Embrace the keyboard http://www.developingandstuff.com/2015/01/no-mouse.html