Write Code Every Day


Last fall, work on my coding side projects came to a head: I wasn’t making adequate progress and I couldn’t find a way to get more done without sacrificing my ability to do effective work at Khan Academy.

There were a few major problems with how I was working on my side projects. I was primarily working on them during the weekends and sometimes in the evenings during the week. This is a strategy that does not work well for me, as it turns out. I was burdened with an incredible amount of stress to try and complete as much high quality work as possible during the weekend (and if I was unable to it felt like a failure). This was a problem as there’s no guarantee that every weekend will be free – nor that I’ll want to program all day for two days (removing any chance of relaxation or doing anything fun).

There’s also the issue that a week between working on some code is a long time, it’s very easy to forget what you were working on or what you left off on (even if you keep notes). Not to mention if you miss a weekend you end up with a two week gap as a result. That massive multi-week context switch can be deadly (I’ve had many side projects die due to attention starvation like that).

Inspired by the incredible work that Jennifer Dewalt completed last year, in which she taught herself programming by building 180 web sites in 180 days, I felt compelled to try a similar tactic: working on my side projects every single day.

Illustration by Steven Resig

I decided to set a couple rules for myself:

  1. I must write code every day. I can write docs, or blog posts, or other things but it must be in addition to the code that I write.
  2. It must be useful code. No tweaking indentation, no code re-formatting, and if at all possible no refactoring. (All these things are permitted, but not as the exclusive work of the day.)
  3. All code must be written before midnight.
  4. The code must be Open Source and up on Github.

Some of these rules were arbitrary. The code doesn’t technically need to be written before midnight of the day of but I wanted to avoid staying up too late writing sloppy code. Neither does the code have to be Open Source or up on Github. This just forced me to be more mindful of the code that I was writing (thinking about reusability and deciding to create modules earlier in the process).

Thus far I’ve been very successful, I’m nearing 20 weeks of consecutive work. I wanted to write about it as it’s completely changed how I code and has had a substantial impact upon my life and psyche.

With this in mind a number of interesting things happened as a result of this change in habit:

Minimum viable code. I was forced to write code for no less than 30 minutes a day. (It’s really hard to write meaningful code in less time, especially after remembering where you left off the day before.) Some week days I work a little bit more (usually no more than an hour) and on weekends I’m sometimes able to work a full day.

Code as habit. It’s important to note that that I don’t particularly care about the outward perception of the above Github chart. I think that’s the most important take away from this experiment: this is about a change that you’re making in your life for yourself not a change that you’re making to satisfy someone else’s perception of your work. The same goes for any form of dieting or exercise: if you don’t care about improving yourself then you’ll never actually succeed.

Battling anxiety. Prior to starting this experiment I would frequently feel a high level of anxiety over not having completed “enough” work or made “enough” progress (both of which are relatively unquantifiable as my side projects had no specific deadlines). I realized that the feeling of making progress is just as important as making actual progress. This was an eye-opener. Once I started to make consistent progress every day the anxiety started to melt away. I felt at peace with the amount of work that I was getting done and I no longer had the over-bearing desire to frantically get any work done.

Weekends. Getting work done on weekends use to be absolutely critical towards making forward momentum (as they were, typically, the only time in which I got significant side project coding done). That’s not so much the case now – and that’s a good thing. Building up a weeks-worth of expectations about what I should accomplish during the weekend only ended up leaving me disappointed. I was rarely able to complete all the work that I wanted and it forced me to reject other weekend activities that I enjoyed (eating dim sum, visiting museums, going to the park, spending time with my partner, etc.) in favor of getting more work done. I strongly feel that while side projects are really important they should not be to the exclusion of life in general.

Background processing. An interesting side effect of writing side project code every day is that your current task is frequently running in the back of your mind. Thus when I go for a walk, or take a shower, or any of the other non-brain-using activities I participate in, I’m thinking about what I’m going to be coding later and finding a good way to solve that problem. This did not happen when I was working on the code once a week, or every other week. Instead that time was consumed thinking about some other task or, usually, replaced with anxiety over not getting any side project work done.

Context switch. There’s always going to be a context switch cost when resuming work on a side project. Unfortunately it’s extremely hard to resume thinking about a project after an entire week of working on another task. Daily work has been quite helpful in this regard as the time period between work is much shorter, making it easier to remember what I was working on.

Work balance. One of the most important aspects of this change was in simply learning how to better balance work/life/side project. Knowing that I was going to have to work on the project every single day I had to get better at balancing my time. If I was scheduled to go out in the evening, and not get back until late, then I would need to work on my side project early in the day, before starting my main Khan Academy work. Additionally if I hadn’t finished my work yet, and I was out late, then I’d hurry back home to finish it up (instead of missing a day). I should note that I’ve been finding that I have less time to spend on hobbies (such as woodblock printing) but that’s a reasonable tradeoff that I’ll need to live with.

Outward perception. This has all had the added benefit of communicating this new habit externally. My partner understands that I have to finish this work every day, and thus activities sometimes have to be scheduled around it. It’s of considerable comfort to be able to say “Yes, we can go out/watch a movie/etc. but I have to get my coding in later” and have that be understood and taken into consideration.

How much code was written? I have a hard time believing how much code I’ve written over the past few months. I created a couple new web sites, re-wrote some frameworks, and created a ton of new node modules. I’ve written so much I sometimes forget the things I’ve made – work from even a few weeks prior seem like a distant memory. I’m extremely pleased with the amount of work that I’ve gotten done.

I consider this change in habit to be a massive success and hope to continue it for as long as I can. In the meantime I’ll do all that I can to recommend this tactic to others who wish to get substantial side project work done. Let me know if this technique does, or doesn’t, work for you – I’m very interested in hearing additional anecdotes!

Discuss this post on Hacker News.

Posted: April 10th, 2014


If you particularly enjoy my work, I appreciate donations given with Gittip.

25 Comments

  1. John Mark Howell (April 10, 2014 at 1:41 pm)

    This is one of the best posts I have seen in a long time!

  2. Philip Guo (April 10, 2014 at 1:45 pm)

    Great! Like a form of Seinfeld’s Don’t Break The Chain for hobbies:
    http://lifehacker.com/5886128/how-seinfelds-productivity-secret-fixed-my-procrastination-problem

  3. Rob Brambley (April 10, 2014 at 2:12 pm)

    I spent the last few months doing this and I could not agree more with what you’ve written. I had a 161 day streak, and I believe it had a really positive effect on my life for many of the same reasons you mentioned – I was better at managing my time, I had less anxiety, and I infrequently had trouble picking up where I left off. Last week, I got back from a ten day trip, and it has been very, very hard to achieve the focus I had during this streak. This is actually kind of depressing, and leaves me wishing I had set aside more time during my trip to do a little bit of coding each day. Before taking some days off from coding, I did not feel exhausted or burnt out, but as friends suggested, it seemed like it would be a good idea to take a break, just for the sake of giving my mind a rest and making sure I wasn’t overworking myself without realizing it.

    In retrospect, I do not regret taking the time off – I knew it was inevitable that I’d need to go some time without coding. But, the next time I do go on a trip or find myself without access to my computer for a while, I think I am going to plan ahead a little better, and think of ways to keep the projects/code/ideas fresh in my head so that it’s not so hard to pick up where I left off. Perhaps this just means writing ideas down on paper on a daily basis, or asking people around me what they think of the latest UI in my app – stuff like this will hopefully help to keep it all fresh in my head.

  4. Adnan (April 10, 2014 at 2:25 pm)

    I am sure you think of project ideas way ahead than you open IDE

  5. Doggy (April 10, 2014 at 2:37 pm)

    Dogfood projects are the best for this.

    For something you yourself use every day, you always know what you need to work on next: it’s whatever bugged you about it the most yesterday. You also get immediate feedback on what you wrote yesterday: you get to use it tomorrow. It’s a daily feedback loop both of incentive, and of productivity.

    I find continuous improvement is difficult for things that I don’t use myself. It means to figure out what to work on, I need to guess, or gather data from users, or listen to a product manager. It means I don’t get to see yesterday’s improvements, except indirectly. It means yesterday’s work doesn’t help make today’s work any easier.

  6. Virendra Rajput (April 10, 2014 at 2:46 pm)

    Hi John,

    this is something I’ve been trying out recently. But I haven’t been able to keep up with the pace. Since, the anxiety of missing one day, kills me. It just breaks the chain. I’ve been trying hard to get time off’s on evenings, but it’s not always possible.

    I might try the early morning coding. Since, its lot easier to start coding with a fresh mind.

    Thanks a lot for this post. It will definitely gives me helpful pointers. :-)

  7. Akshay (April 10, 2014 at 2:51 pm)

    Very inspiring John. Nice points on how to keep the streak continuing

  8. Max (April 10, 2014 at 3:06 pm)

    Very, very, very inspiring. I’m in the same situation as yours before your started your journey.

    I’m going to try this experience starting tomorrow.

    Thank you.

  9. Antonin Januska (April 10, 2014 at 3:23 pm)

    I’m actually starting off a similar project, came up with it last week: the 30 days of Git Commits; however, I like your 20 weeks better.

    The main issue I have with structuring your life this way is the pure amount of time you’re spending on coding. I work as a programmer in my day job, that’s 7-8 hours of solid coding a day (with breaks of course).

    Adding another 30 minutes on top of that should be fine but never at the cost of another hobby. At least to me, because then my “side projects” begin to feel like work, and I do enough of that already ;)

    What I started doing last year (or maybe the year prior to that) is a concept of “monthly goals (http://renewlifebalance.com/?/monthly-goals/ <- wrote about it here). Which is basically the idea of picking a subject, whatever hobby, or work, or whatever, and focusing on just that for a month. And the focus greatly helps alleviate the ADHD-type behavior where you have time and either mis-spend it or can't figure out what to focus on.

    It's the same concept as writers doing NaNoWriMo, or coders doing a 30-day git commit sprint.

    I hope you get back to the woodblock printing and enjoy that for a change! :)

  10. Skyul (April 10, 2014 at 3:24 pm)

    Inspiring indeed, but you should mention that even if you write daily code, never forget about your personal life, including friends and family.
    After all you are just chasing your dream, but don’t forget about others.

  11. João Netto (April 10, 2014 at 3:27 pm)

    I’m doing almost the same except by the fact that i’m not FORCING to get something done every single day.

    Almost ever, my weekends are totally designed to I have some fun and if i start to write something i bought me some prize.

    Nice post!

  12. Fernando Briano (April 10, 2014 at 3:29 pm)

    I’ve been trying this same thing since March 1st!
    https://github.com/picandocodigo

    I got a 35 days streak, took two days off, and now continue with a new streak. But I’ve seen all the advantages you mention on this blog post in my daily routine. Mostly background processing, since I’m always thinking of new ideas to implement both as new projects or as improvements to my current projects.

    I still work on refactors, docs and similar stuff some of the days. I also love midnight coding, though sometimes it extends to 4am coding and I am not so happy the other day when I check out the code I wrote at 4am :P
    Those are the parts I need to improve the most, but I fully agree with the post and the advantages of writing code every day.

  13. Paulo Eduardo Neves (April 10, 2014 at 3:49 pm)

    I’ll follow your idea. I loved the commit chart. Does anybody here knows if BitBucket also has a chart like this one?

  14. Angel "Java" Lopez (April 10, 2014 at 3:59 pm)

  15. Brad L (April 10, 2014 at 4:07 pm)

    Great Post. I am struggling with this exact problem. The anxiety is killing me. I am going to put these principles in place immediately!

  16. Paul (April 10, 2014 at 4:08 pm)

    On average, how long do you spend everyday on your side-coding? Do you try to set a reasonable minimum and maximum?

  17. Doggy (April 10, 2014 at 5:04 pm)

    Antonin: Where do you work? I want to work there! I’ve never had any programming job where even 50% of my day was spent writing software.

  18. Tushar S (April 10, 2014 at 5:35 pm)

    I think this is called the Jeremy Seinfeld ‘Chains’ method – as in don’t break the chain!
    Although github already shows us the chain, some people could use https://chains.cc/
    to track various activities.
    The main problem for me has been to start and stick with this for a few days at least, and then the habit establishes itself. It’s the first week that’s crucial.

  19. Chewxy (April 10, 2014 at 5:43 pm)

    Hey John,

    So how did you get into the habit of it? Did you just sit down and say “I’m not leaving this desk until I have some code done”?

  20. Patrick Ford (April 10, 2014 at 6:07 pm)

    I recently started the same discipline. I spent a good part of my career writing code then worked my way up to executive management and stopped. After several years as Director of this, or VP of that, my skills had eroded. Late last year I decided to take a sabbatical and get back into the game by applying to Hack Reactor in SF. It was an intense period of two months of pre-course work (18 Code School classes and a bunch of coding assignments), followed by three months of intense work on site where we went 11+ hours a day for 6 days a week. One of the disciplines there is to work on a short “toy problem” every morning for 30-60 minutes. Although I finished the program recently I am keeping up that practice as well as working on my real project, a new startup for social video. I’ll never stop coding again!

  21. teoman (April 10, 2014 at 6:37 pm)

    Thanks so much, great blog post!

  22. Asim Suvedi (April 10, 2014 at 6:59 pm)

    WOW ! That’s my story (the problem part). Thank you for writing.
    I plan to do so much on on weekends and I get depressed for not completing the TODOs.
    I think it’s important not to Plan too much and do less at a time. With information overload, we just forget we are humans not computers and try to do a lot of things which backfires instead.

  23. TuxLyn (April 10, 2014 at 6:59 pm)

    Consistency is very important, I’ve been coding for many years now most of the code Is private. But I’ve always tried coding daily, this makes you think about code and fix bugs even in your dream ^_^ Good post thank you.

  24. lovejoy (April 10, 2014 at 7:26 pm)

    My coworker has a streak over a month now, and I may join. Keeping count is itself a turn-off for me, so I’ll need the mindset of just counting to two: yesterday and today. This suggestion could help improve my favorite side work, by not cramming 7 hours in the dark between Saturday and Sunday.

    P.S. I love Steven Resig’s illustrations, but it seems his server’s doing its best just to load the thumbnails; larger versions were inaccessible.

  25. Shane (April 10, 2014 at 7:44 pm)

    This resounded with me. I just came to many of the same conclusions you touched on. After years of continually starting and never completing side projects I came to the slow realization that something needed to change. I also forced myself to code everyday (weekends included) and developed the habit of doing at least a couple hours first thing in the morning. Thanks for the post and reaffirming the benefits.

Leave a Comment

Note: Wrap all of your code blocks in <code>...</code> and replace < and > with &lt; and &gt;, respectively.

Secrets of the JavaScript Ninja

Secrets of the JS Ninja

Secret techniques of top JavaScript programmers. Published by Manning.

Ukiyo-e Database and Search

Ukiyo-e.org

Japanese woodblock print database and search engine.


John Resig Twitter Updates

@jeresig

Infrequent, short, updates and links.


via Ad Packs