When I was young and has just started to learn programming, I read some descriptions of what programming was like as a job. These fell roughly into one of two categories:

  • long meetings, and writing a lot of documentation
  • long days of furious hacking fuelled by chemicals

That was decades ago. I have since learn from experience that a programmer's productivity is best boosted by:

  • knowing clearly what to do
    • a well-defined goal is easier to reach than one that is unclear or changes all the time
  • knowing one's tools and being comfortable with them
    • the exploration phase of using a new tool is rarely very productive
  • not being interrupted while doing it
    • being in the flow is commonly preferred, but may or may not be necessary; however, frequent interruptions are anti-productive in any case
  • getting enough sleep
    • continuous yawning is distracting, concentration is difficult if your brain is hallucinating from lack of sleep
  • avoidance of bad stress
    • stress that makes you worry about the future is bad
  • having a reliable source of lapsang tea
    • but I need to stop drinking it at least six hours before bedtime, or I sleep badly
  • a comfortable work environment

It further helps to use various tools that allow the programmer concentrate on cranking out the code:

  • automated language checkers
    • statically types languages require you to get types right, and will catch you if you mistype a variable name
    • static checkers for dynamically typed languages can often do the same job
    • either way, they help you catch errors earlier, which means you spend less time waiting for an error to happen
  • automated tests
    • unit tests, integration tests, etc, allow you to avoid spending time and effort on doing the same tests manually over and over
  • reuse of high-quality code
    • this means libraries, code generators, tools you can run, etc
    • these save you time by not having to write the code yourself
    • they further save time by not having to debug the code you wrote
    • however, beware of low-quality code; it won't save you time, since you'll almost certainly have to debug and fix it yourself
  • automated systems to run your automated tests
    • continuous integration runs without you having to remember to run your tests
    • it also runs them in the background, meaning you don't need to wait for them to finish, which is especially useful when you have slow tests
    • the tests also get run in a well-defined environment, rather than the developer's randomly configured ever-changing laptop
  • automated system for installing software on target machines
    • continuous delivery takes care of installing your software somewhere you can use it, which may or may not be the production server
    • this is especially useful for server, web, and command line software, but is generally useful
    • often the process of installing manually is tedious - just like doing manual testing - so the more it's automated the less time you waste on repetitive work