Programming is appealing in a way that many skills are not. It pulls at you, makes you feel as if there's an itch you want to scratch. This magnetic quality is one of the deeper reasons why developers learn how to program and why they keep on doing it.
Programming feels this way because you can immerse yourself so deeply into it that you forget about yourself. For a moment, your problems and fears melt away as you focus on the code. This is a highly rewarding experience. You're in the zone or, as psychologists call it, experiencing a flow state of mind.
This article will explain what flow means, why it feels so good, which conditions need to be met to fall into flow easier, and how it all relates to happiness.
What is a Flow State of Mind?
The Hungarian-American psychologist Mihaly Csikszentmihalyi coined the term "flow" in 1975, but the concept has existed for thousands of years under different names. It's what Aristotle called eudaimonia, the Taoists call wu wei, and the Buddhists call zen.
Flow is the mental state of deep immersion and presence in an activity. In his 2004 TED talk, Csikszentmihalyi spoke about the seven conditions that are at play when someone is in a flow state of mind:
- Intense focus. The person is deeply involved in whatever they're doing.
- An alternative reality. They feel as if they're outside of the everyday, dull routine of daily reality.
- Inner clarity. They know what needs to be done in order to progress and achieve their goal.
- Skill/Challenge ratio. They know that they're just skilled enough to complete the challenge.
- A sense of serenity. They are not thinking about their everyday problems and fears.
- Timelessness. They are less aware of time. Hours can pass by in what seems like minutes.
- Intrinsic motivation. The activity feels rewarding in itself. There's no external motivator they are thinking about.
Those who have mastered a particular skill will be familiar with the feeling described above. Flow is everywhere: figure skaters, poets, composers, writers, athletes, and programmers are all capable of experiencing flow.
Why Does Flow Feel So Good?
Flow is a highly rewarding experience because your brain produces these chemicals when in flow: norepinephrine, anandamide, serotonin, dopamine, and endorphins. All of these are performance-enhancing chemicals that make you feel good.
There's also the rewarding feeling of being productive and working on something that you're just skilled enough for to complete properly. Psychologists Antonella Delle Fave and Fausto Massimini illustrated this skill/challenge ratio in what they called the Experience Fluctuation Model:
While the model is not without its problems – people don't always feel apathetic in low-challenge/low-skill situations – it neatly illustrates the fact that flow happens in challenging situations where you're also highly skilled (the top right corner).
How to Fall into Flow Easier
Let's start with a disclaimer: Just like you cannot force yourself to be happy, you cannot force yourself into flow. It needs to happen naturally. This being said, you can put yourself in a particular mindset and set your environment up in such a way that it becomes easier to fall into flow.
Firstly, there's a certain skill threshold in order to achieve flow. If you're just starting out as a web developer and you're still learning the difference between grid and flexbox, it's unlikely you'll be able to induce a flow state of mind.
This shouldn't be looked at as discouraging. It's simply another reason to keep on learning. The more skilled you are in what you're doing, the easier it will be to get into flow and the deeper your flow will feel.
Secondly, and this is related to the first point, you can use the Experience Fluctuation Model to determine whether you need to increase or decrease the challenge. If what you're doing feels easy, make it harder. If what you need to do makes you feel anxious, break it up into easier, more digestible pieces or keep learning until you feel you can do it.
Thirdly, the task at hand must provide you with clear and immediate feedback. For a programmer, this is relatively easy: tests and errors can provide you with instant, near-continuous feedback that help you adjust your behavior as you progress in the task.
Fourthly, it helps if there are consequences attached to the task. We feel more deeply involved if there's some level of risk. This comes naturally in action-adventure sports where a mistake can lead to an injury, but it needn't just be physical risk. It can be emotional or social risk too. That's why an accountability buddy works; they introduce an element of social risk that makes you pay more attention to the task at hand.
Finally, flow is broken when you're interrupted. Makes sure your environment and the people around you do not interrupt you when you're trying to get into flow. Block out a few hours on your calendar, put your smartphone in a different room, and make sure you turn notifications off on the device you're working on.
How Does Flow Relate to Happiness?
Happiness is a byproduct of doing highly rewarding activities, i.e. activities that induce flow. Scientists consider flow "autotelic", which means that it's rewarding in itself.
When you don't rely on external motivators like money and material resources to determine your happiness, you'll be more resistant against shocks that would otherwise have impacted your happiness.
Additionally, a flow state of mind means that you're fully present in the moment. In that sense, flow is a close cousin to mindfulness, which reduces stress and improves how peaceful and calm you feel. In fact, if you cannot get into flow, it's a good idea to take a page from the book of mindfulness and consciously focus on the task at hand.
Don't chase happiness. It ebbs and flows (no pun intended) and will always do so. Instead, focus on getting extremely good at a particular skill and set up your environment so you fall into the highly rewarding feeling of flow whenever you look at the code you're writing.