Happy Code
You

Happy Code is momentum

Most enjoyable activities are not natural; they demand an effort that initially one is reluctant to make.

Mihály Csíkszentmihályi

The easiest way to get nothing done
is to stay busy around the code
without staying with the code.

Open one more tab.
Check one more thing.
Switch to one tiny task.
Quickly answer a question.

Come back and reload the whole problem in your head.

Small interruptions may not ruin your progress,
but they shatter your immersion.

And when this happens often enough,
you can spend a whole day in motion
without ever gathering momentum.

Happy Code starts when you protect your attention.

One thought becomes one action.
And one action makes the next thought obvious.

You change something.
It runs.
Or it does not.
Either way, you learn something.

The code answers.
You answer back.

That is momentum.

You could also call it flow,1
or being in the zone.

It is what happens when the gap between thought and result
gets short enough that you stop noticing the gap at all.

It is no longer about forcing yourself forward.
It is about the work feeling good
instead of just feeling hard.

You are still spending energy.
You may even be tired when you are finished.

But the reward is no longer postponed until the end.
It is felt while you are doing it.

Think of the goal in front of you as a tree.

At the top is the thing you actually want:
a finished feature,
a fixed bug,
or a completed refactoring.

Below it are branches:
the parts that have to work.

Below those, lower branches:
the sequence of steps to get there.

At the bottom are the leaves:
the immediate moves you can make right now.

You do not climb this tree by staring at the top.
You climb it by solving one leaf.
Then another.
Then a branch becomes done.

Solving it changes what you can see.

A new branch becomes reachable.
An assumption you were defending turns out to be wrong,
while it still costs nothing to change.

The shape of the problem sharpens
because you stayed with it long enough
to see the actual solution reveal itself.

A single step does not need to be big.
Extract a method.
Write the test.
Print the object and look at it.

Concrete. Small. Working.

Something that makes the system respond.

Because once it responds, you respond back.
And once you respond back, the loop is alive.
That is when you start clearing the branches.
One problem closes.
The next one opens.
Then the next.

There is only this branch now.

Your attention stops scattering.
The hour disappears.
The coffee goes cold.
You look up surprised that it is dark outside.

This is the trance developers remember.

Something was only in your head.
Then it became reality.

You do not get there by concentrating harder.
You get there when each finished step
makes the next one easier to see.

So when the work feels scattered,
protect your attention.

Do not touch five branches at once.
Do not confuse motion with momentum.

Make one move.
Pick a leaf you can actually finish
and finish it.

The top gets closer.
The next step gets clearer.
The code starts talking.

And then you are in it.

Happy Code is momentum.

One step after the next,
until the imagined path becomes real.


  1. Mihály Csíkszentmihályi, Flow: The Psychology of Optimal Experience (1990), a book about deep absorption in an activity when skill, challenge, attention, and feedback line up. ↩︎