How to Program for 24 Hours Straight

August 26, 2021

DALL·E 2022-08-07 11.39.06 - An illustration of a desk with the following things on it a laptop, coffee in a thermos, speakers, and a notepad with scribbles on it. It's night tim.png

An illustration of a desk with the following things on it: a laptop, coffee in a thermos, speakers, and a notepad with scribbles on it. It’s night time. In the window off to the left, you can see the glow of the night time city lights.

Writing software takes a lot of focus, and unfortunately we can’t just snap our fingers and be instantly in the zone. It takes time, but there are a bunch of things we can do to help that along. This is a list of things that I’ve found over the years that really help to put me in a flow state.

  • Get a long music playlist that is specific to programming. Music can be a very good way to get you into a mindset. Much in the same way a song can give you nostalgia, by reserving a set of songs for programming you can trigger a way of thinking just by turning on a playlist.
  • Have a single project or subsection of a project that you can focus on. Having a specific theme of problems will help maintain flow. You don’t want to give yourself mental whiplash by going from app development to web development to robotics to devops to frontend.
  • Write down everything you need to get done. Take 10-20 minutes before you begin to think through what needs to be completed and write it down – don’t just keep a mental checklist. If you’re trying to keep a mental checklist of everything that needs to get done you’re wasting brain power on something that isn’t solving your problems.
  • Write down way more things than you think will be possible to do. Normally my flow sessions are between 6 and 24 hours. If I’m intensely focusing for that long, I’m going to be getting a lot done, so I need to be prepared for it. I write down an obscene amount of things that need to get done, more than I could reasonable do in several days in a normal situation. Then once that’s done, I tell myself that I’m not allowed to sleep or stop until all the things on that notepad are done. Sometimes I finish the list, sometimes I don’t, but that’s not the point. The point is there is always another well defined problem for me to tackle once I solve something on my list, which in turn keeps me plugged in.
  • Get a good night’s sleep beforehand. If all you can think of is how tired you are and how much you’re looking forward to sleeping, then that will undermine every other point in this article. These methods will be most effective if you’ve had a good night’s rest before hand.
  • Hot Coffee or Hot Tea in a travel mug. Having coffee or tea in a travel mug as opposed to an open cup has several benefits. First of all it keeps your drink hot for hours which slows down your consumption. You won’t get a massive burst of caffeine but rather a slow ingestion which is much better for what we are trying to achieve here. It’s like the difference between doing a 100 meter dash and running a marathon. The second thing, as a result of the slow consumption, is that you will have less bathroom breaks (which break flow state).
  • Block off a chunk of time where you won’t be distracted. This method doesn’t really work if you try to block off six thirty-minute chunks of time with breaks in between as opposed to one three hour chunk. Make sure your schedule is free.
  • Turn off your phone and place it in a location that isn’t readily accessible (like in a drawer or another room). Every notification is a distraction and an opportunity to break a flow state. Once my phone is out of sight I find it very easy to forget about it and just keep coding.
  • Exit out of all tabs and windows that are not directly related to the programming problem you are trying to solve. Removing unrelated tabs and windows is just another method to help keep me focused.
  • Dark mode for everything and/or sunglasses. The goal behind this method is to reduce eye strain. I personally use the Dark Reader browser extension to make viewing web pages at night easier. I use sunglasses during the day to block out excess light which helps prevent eye strain.

I’ve used these methods many times with much success. The goal is always to enter a sort of meditative state. If you have someone who wants to start a conversation with you, shoo them away. If your phone is vibrating from notifications so much that it registers on local Richter scales, turn it off. Make it clear both to other people and yourself that you are not to be disturbed or distracted. Humans have a limited amount of willpower, and the less energy you spend on combating distractions will be more energy you have to focus on writing software.