I struggle a lot with motivation. This is probably not an unfamiliar story - there is some exciting project I want to work on but every time I try to get started my mind just shies away and reaches for the reddit refresh button.

There is a lot of advice on the subject. Some of the advice is basic sanity maintenance like getting regular exercise, nurturing your social life, eating healthily and taking time out. This is sensible advice. Other advice revolves around shoring up motivation through blocking websites, setting timers, tracking goals etc. I find this kind of advice unhelpful.

The reason it’s unhelpful is that procrastination is fundamentally a monkey-brain problem and that these are all human-brain solutions - bandaids over a gaping wound.

Rather than wrestle with willpower I’ve found it much more useful to directly attack the underlying problems. The two main problems that I suffer from are lack of rewards and lack of a plan.

Lack of rewards

Not big rewards, like a meaningful project or high status or good salary or lots of perks. The monkey-brain is not into complex cause-effect chains or long-term consequences. It only cares about here and now. If every time I look at an editor I feel stressed and tired and nothing pleasant happens immediately afterwards then the monkey-brain will just refuse to look at the editor anymore. Procrastination sets in.

Some projects are easy to sell to the monkey-brain. If I’m doing optimisation work then I get to run benchmarks. Sometimes I run a benchmark and the numbers have gotten bigger! Monkey-brain is really into frequent, unpredictable rewards so it lets me work on optimisation for hours on end without needing distraction.

Other projects just need better planning. A common trap I used to fall into was to start a project where the todo list looks like:

Usually I make it as far as hard thing C before the monkey-brain decides that this sucks and we should go eat icecream instead.

These days when I plan projects I try to front-load the shiny. For example, when working on Imp I could have broken up the work by subsystem: write the runtime, write the compiler, write the parser, write the repl. But the exciting, motivating part is getting to play with the repl and that wouldn’t have happened until right at the end. Instead I broke it up by feature: get inputs working, get joins working, get functions working etc so that every chunk of work results in a new toys to play with.

Some projects really are just a grind and the only way to avoid burnout is to mix in other rewards. If I have to spend weeks refactoring some gnarly legacy code, I will also take time out to work on little projects that I can finish easily, just to make sure that the monkey-brain doesn’t get the impression that programming sucks in general.

What actually constitutes a reward probably varies from person to person. For some people, the satisfaction of seeing clean code checked in or a suite of tests passing might be enough. For me, the only reliable rewards are numbers getting bigger or new toys to play with, so I have to make sure that those happen.

Lack of a plan

There are lot of ways my momentum can break down: I can’t figure out how to solve some problem, I can’t decide what to do, I don’t know where to start etc. What they all have in common is that nothing is happening, there is no clear next step and I just wallow in the quicksand of indecision. This can go on for weeks. The way I’ve learnt to deal with this is to have pre-planned procedures that get triggered when I notice one of those failure modes.

If I can’t figure out how to solve some problem:

If I can’t decide what to do:

If I don’t know where to start:

The key thing about all of these is that they generate momentum. As long as I am systematically attacking a problem I will get somewhere. The failure mode to avoid is just circling around on the same thoughts again and again until the monkey-brain freaks out about the lack of progress and calls for icecream and cat videos.