By September 13, 2021

Proven Ways of Getting Into a Productive Mental State

This is a chapter from the upcoming book “The Successful Programmer Mindset” which we will be publishing first on Simple Programmer. You can find out more about the book, and its upcoming launch, by clicking here

Only through focus can you do world-class things, no matter how capable you are.

—Bill Gates, a co-founder of Microsoft     

programmer productive mental stateGood programming habits are essential for being a great programmer. And there are many different habits that you need to master to put yourself way above most of your competition: writing your code according to best practices; creating productive routines; and surrounding yourself with cues that will help to keep procrastination at bay. These habits help you to improve your performance by automating your actions, which, to some extent, automates your output. And these habits alone will make you stand out from the crowd. But a specific skill that will make you stand out even more is knowing how to get into the state of deep work.

When you acquire the habit of setting aside all distractions while you work, you have made it easier and quicker to complete the task that you were planning to complete. Add this to the fact you have already developed the skill to produce well-written code on autopilot. But when you merely work on autopilot, you will still be thinking about the things that have nothing to do with your work. Remember how sometimes you can’t remember making a journey in your car because you were driving on autopilot and thinking about other things?

Autopilot is fine, but it would be much better (and much more enjoyable) if you could focus entirely on the task that you are doing. The quality of the output will then go over the roof and there will be a smaller chance of bugs creeping into your code. This will also help you to complete the task quicker, which will make it easier to stick to the schedule and increase the overall performance metrics. Likewise, your work-life balance will improve if you can achieve more within a shorter period of time. The process of dedicating your entire focus to the task at hand is known as “deep work”. And there is a mental state that is conducive to it.

Achieving a certain mental state may sound well outside of your comfort zone. But what if I told you that the ability to enter that mental state is in itself nothing but a habit? What if I told you that you can learn to enter it almost at will? And what if I told you that mastering the skill of doing highly focused work will improve the overall quality of your life?

Why deep work matters to your success as a programmer

The ability to do deep work is an acquired skill. It has to be consciously developed through finding the optimum mental state and building the right habits to help you get there. Mastering it takes time, just like it takes time to build any other productive habit. But, once mastered, it will make building the other right habits easier.

It’s very common for programmers to listen to something in the background while working. Many struggle to focus on a single activity for too long and they regularly take breaks to browse the web or do any other unproductive activities. This is the opposite of the concept of “deep work” – when all undivided attention is fully focused on a single task for a prolonged period of time.

Coincidentally, the term “deep work” has actually originated from computer science. It was coined by Calvin C. Newport, who is an associate professor of computer science at Georgetown University and a bestselling non-fiction author. In fact, “Deep Work” happens to be the name of one of his best-known books.

Why he thinks the ability to do deep work is important can be summarized by this quote from his book, which says there are, “Two Core Abilities for Thriving in the New Economy 1. The ability to quickly master hard things. 2. The ability to produce at an elite level, in terms of both quality and speed.”. [1]

To master hard things, you have all the time in the world. But to master them quickly, you need to focus for long periods at a time. For this, you need the ability to do deep work.

The speed at which you master hard things is especially relevant for any career in the IT sector, including programming. It’s not a secret that technology evolves at a rapid pace. Therefore, if you are too slow to learn something, the stuff that you have spent so much effort learning becomes irrelevant once you master it.

Likewise, to be able to produce at the elite level, where the output is both quick and of high quality, you need to be able to focus. Yes, you can produce things quickly without much focus. But you will probably overlook something in the process, which will introduce defects into your output or otherwise reduce the overall quality of it.

Finally, another advantage of being able to pay undivided attention to your work is that this ability is relatively rare. Not many developers consciously study it. Therefore, if you master it, you will stand out. Your performance will be visibly better than that of your competitors. And you will probably be making less mistakes and introducing less bugs than them.

Why deep work isn’t something we are naturally good at

But there is a reason achieving the optimum mental state that allows you to do deep work isn’t commonplace: our brains are not naturally built to do it. Our natural instinct would be to provide as little focus as possible to something that is intellectually challenging to conserve that all important energy. And brains don’t like boredom either. So, unless you consciously cultivate the habit of deep work, you will probably be among the ranks of those who regularly procrastinate and never pay 100% attention to any work-related task. [2]

Remember how Anatoly Karpov lost 10 kg (or 22 pounds) of bodyweight during the chess tournament of 1984 purely because of intense focus on the game? That’s precisely why our bodies don’t like to keep our brains focused and will do anything to try to preserve the energy. But the irony is that by forcing yourself to try maintaining the focus while your body is telling you not to is probably something that will waste even more energy.

Because programming is intellectually challenging, the best and quickest way to solve a programming problem is by fully focusing on it. To solve pretty much any programming problem other than copy-pasting boilerplate code, you will have to create some abstract steps in your head that would lead to the solution. And this is hard to do if your attention is split between this problem and somewhere else.

If you struggle to maintain your undivided focus on a problem, you may still be able to solve it, but it will probably take you longer than it would be for someone who gave it 100% of focus. And if you constantly jump between work and something else, you will have to rebuild all the abstract models in your head every time you return to the problem. It wastes a lot of effort and mental energy. People who haven’t made deep work their habit often feel mentally-drained towards the end of the working day.

Repeatedly shifting attention between work, news and social media is known as context switching or multitasking. [3] Those who are acquainted with how computer processors work, will be familiar with what context switching is. In a nutshell, it’s about running multiple threads and switching between them, while each thread maintains its state. It’s something that should be avoided, as it slows down a computer's performance. [4] Even though every single context switch doesn’t take a lot of mental energy, doing many of them throughout the day makes the wasted energy add up. The tiredness towards the end of your day will be almost guaranteed.

programmer productive mental stateContext switching also significantly slows down the performance of the brain in a similar way that it slows down computer performance. This is why pretty much all psychologists, management consultants and productivity coaches unanimously agree that it’s bad. The reason why it is bad is the same as with computers. When a thread gets suspended to execute another thread, the resources need to be dedicated to save the state of the original thread. Likewise, when you switch from one task to another, the residue of your original task remains in the brain.

Of course, there is nothing wrong with listening to something in the background while you are doing some basic set-up task or copying some boilerplate code. These sorts of tasks aren’t challenging, so your performance won’t be affected by some nice music or a podcast. In fact, it might actually be useful to play something in the background in this case to make sure that you don’t get excessively bored and lose your focus completely. But those types of tasks are special cases and perhaps the only exception.

Doing deep work is challenging at first – as we’ve seen above the brain isn’t naturally wired to desire deep work. And it takes more than developing routines or forming habits. The best way to do it is to learn to get into a special mental state that will make it easy.

Why the ability to do deep work depends on your mental state

An important point about deep work is that it’s best done when you aren’t in the same mood as you are while you aren’t working. You aren’t focused on a single thing most of the time throughout the day. When we are in a normal semi-relaxed state, our attention wanders between different parts of our external environment and our internal thoughts. So, in order to start deep work, you will need to shift into a different mental state.

This is why the hardest thing about deep work is to start it. Suddenly, all the stimuli that you were normally surrounded by temporarily cease to exist. And while your mind was wandering freely just a minute ago, you are now trying to focus it. You will feel bored. And this is precisely why that’s the time when you will probably get the strongest possible urge to procrastinate.

If deep work was easy, it would not be called “the superpower of the 21st century” by Calvin C. Newport, the author of “Deep Work”. This is what else he says about it: “Deep work is hard and shallow work is easier and in the absence of clear goals for your job, the visible busyness that surrounds shallow work becomes self-preserving.” [1]

But how exactly do you get into the mental state that’s conducive to working deep? Well, certainly not by willing it to happen. Alteration of your mental state is not what you will have to consciously think of. It will happen on its own. But you will need to start on your task and stay fully occupied by it for at least 15-20 minutes for this to happen. And that’s the hardest part. But on occasions, acquiring and maintaining focus happens almost involuntarily.

Everyone is familiar with a situation where they didn’t feel like doing something. But after actually starting on the task, they haven’t even noticed how they eventually became fully occupied by it. But right at the beginning, they were probably still thinking about the things they were doing before they got started. That’s an example of the mental residue left in your brain from context switching. And this is why you will probably have a short period of time (10-15 minutes) when you will have to consciously force yourself to focus. Then, once your brain has adjusted, you will just get on with it.

But if you have allowed yourself to build a bad habit of procrastinating every time you feel like it, you may never enter the required mental state. And, as a consequence, you won’t really learn how to do any deep work. This is a very dangerous habit that may cost you your career. And, just like any other nasty habit, it will appear like a weed without any effort from your side, as long as you aren’t consciously addressing it.

But if you have successfully managed to get into the state of deep work on a regular basis, it will start becoming easier and easier. Partially, because repeated action will build the relevant neural pathways in your brain. But also because you will get familiar with the productive mental state of deep work and you will start enjoying it and seeing it as an opportunity for growth.

Scott Hanselman, a famous senior software engineer from Microsoft who is known for his hyper-productivity, has deliberately designed his working routine to make getting into the state of flow easily. He practices aggressive elimination of all distractions and this is what he repeatedly attributed to his success. These are some of his quotes about the importance of it:

“Remember that anything important that happens in the world, in the news, in your life, in your work , will come your (way) many times, if there's another 9-11, somebody will tell you. You probably didn't learn it by hitting refresh on your favorite news site.”

“Be wrapped up like a child in the thing that captures your attention, get that excitement back, and that excitement does not involve Alt-Tabbing over to Gmail.”

Perhaps, it will even become some sort of an addiction. And you will start looking forward to your next “fix”. But if an addiction can make you work better, improve your pay, career prospects and work–life balance, it’s certainly not a bad addiction to have.

There is even a scientific name for the mental state that is conducive to deep work – the state of flow. Likewise, there are scientifically-proven reasons why doing deep work in this state is something that you will enjoy.

The state of flow – a trance-like mental state of high productivity

programmer productive mental stateYou may have already heard the expression of “being in the zone” or “experiencing the state of flow”. For example, a basketball player may execute a perfect throw. Or a musician may perform a perfect cover of some song. Perfect execution of some action is just an outward expression of the state of flow. What’s more important is what happens on the inside – inside your head. The state of flow is an altered state of consciousness. The actions are just the symptoms of that.

When you are “in the zone”, it feels like time doesn’t exist. You do things spontaneously, but it’s very different from doing things subconsciously on an autopilot. In the state of flow, you are fully aware of your actions. And it just happens that you perform the right actions at the right time. This is why it’s called “the state of flow”. Instead of constantly thinking what to do next, you just do what your body wants you to do. It’s just going with the flow instead of fighting the current.

And it’s not just some sort of metaphysical mumbo-jumbo that happens only to some highly-impressionable people. The state of flow is real.  It was discovered by science and the whole branch of science was developed to study it.

First named by prominent psychologist Mihaly Csikszentmihalyi in 1975, it was discovered by studying high-level performers, such as artists. The best-performing ones seemed to be able to get lost in their work. And they enjoyed the experience.

And it’s not an accident that Csikszentmihalyi dedicated his life to studying this emotional state. He grew up in Europe during World War 2 and, as a kid, he saw the amount of misery that the war has caused. And, as he said in one of his best-known TED talks, this is how he got interested in this type of research:

“I grew up in Europe, and World War II caught me when I was between seven and 10 years old. And I realized how few of the grown-ups that I knew were able to withstand the tragedies that the war visited on them — how few of them could even resemble a normal, contented, satisfied, happy life once their job, their home, their security was destroyed by the war. So I became interested in understanding what contributed to a life that was worth living. And I tried, as a child, as a teenager, to read philosophy and to get involved in art and religion and many other ways that I could see as a possible answer to that question. And finally I ended up encountering psychology by chance.” [5]

Eventually, after interviewing and examining countless people, Mihaly Csikszentmihalyi and his team determined that it wasn’t merely an accident of birth or some lucky circumstances that made people go into this mental state. The state was replicable and pretty much any reasonably healthy individual was capable of entering it. Moreover, the state had a number of measurable and consistent characteristics.

These six components that are always present during the flow experience were identified:

  • Concentration that is intensely focused on the present moment
  • Action and awareness are perceived to be one
  • Sense of self disappears
  • A strong sense of control over the present situation
  • Distorted perception of time
  • Sense of pleasure from the activity being performed

State of flow requires all of these components. If any of these is absent, you aren’t really in the state of flow. [6]

The reason why state of flow limits parts of your perception (losing sense of self, sense of time being distorted, etc.) is because the human brain has a limited capacity to process the information. We simply can’t pay attention to everything that’s happening in our environment at any point of time. It’s way too much. So we only focus on those bits of information that are relevant.

But when you are in the state of flow, your entire focus is allocated to a single activity that you are engaged in. Nothing outside of it exists to your perception. And this is why, although you perform most optimally while you are experiencing the flow, you may become completely oblivious to any other potentially important things. But this is also what prevents you from being distracted. As Csikszentmihalyi said:

“Well, when you are really involved in this completely engaging process of creating something new, as this man is, he doesn't have enough attention left over to monitor how his body feels, or his problems at home. He can't even feel that he's hungry or tired. His body disappears, his identity disappears from his consciousness, because he doesn't have enough attention, like none of us do, to really do well something that requires a lot of concentration, and at the same time to feel that he exists. So existence is temporarily suspended. And he says that his hand seems to be moving by itself. “

Simply put, the mental energy that is normally dedicated to other parts of your perception are rerouted onto the activity that you are currently engaged in. Your brain is probably consuming as much energy as normal, but your task gets more of it, while everything else gets none. This is why the focus on your activity is intense, while everything else, even the perception of self, ceases to exist.

Most people have experienced the state of flow. If you are a keen gamer, you can probably remember some moments when time stood still and you were fully immersed in the game. Or maybe you took part in some extreme sports. While you were engaged in the activity, nothing seemed to exist. And you probably didn’t even have to put effort into getting into this state. It just came naturally.

The top NBA players are well known for getting into the state of low on a regular basis, or “getting in the zone”, as they tend to refer to it. One of the most famous players, Kobe Bryant, said the following about the process:

“It's hard to describe. You just feel so confident. You get your feet set and get a good look at the basket—it's going in. Even the ones I missed I thought were going in.”  [7]

The good news is that it’s not only the fun activities where you can experience the state of flow. You can learn to experience it while performing any creative endeavor. Writing software code just happens to be one of such activities.

But being hyper-focused on your task is not the only benefit of the flow state. Any activity that you do in this mental state feels pleasant. You just don’t want to stop during this activity. And if you manage to get into this state often enough, you will start looking forward to these activities. This is precisely why truly exceptional coders love to code. It’s not the syntax of any given programming language that’s exciting. And it’s not the logic of the program either. What they actually love is the mental state that they are in while being fully engaged in the process of coding.

Learning something complex and then being able to fully immerse yourself in it gives you a sense of empowerment. This is, for example, what Scott Hanselman said about why he enjoys coding:

“Learning to code, to me, is no different from me having someone teach me basic woodworking, gardening, or kitchen tile. After each of these projects my sense of personal empowerment increased. In each situation learned how to think about a problem and solve it. I can do this. I can change my world.” [8]

Another important factor is that this mental state doesn’t drain much mental energy. You don’t have to consciously strive to maintain hyper-focus once you’ve achieved this productive mental state; at this point it is self-maintaining for a long time.

All of these factors are the reason why the state of flow is the best mental state to do deep work in. But there’s more to it.

Why state of flow is the easiest way to do deep work in

Deep work isn’t exactly the same thing as the state of flow. Yes, these two things overlap. But deep work refers to the type of activity that you do and not the mental state you do it in.

Broadly speaking, you can be in one of three mental states while doing deep work:

  • Actively trying to suppress distracting thoughts and forcing yourself to concentrate.
  • Experiencing low-level boredom.
  • Experiencing the flow.

Why forced focus is counterproductive

programmer productive mental stateYou already know that it is incredibly hard to be productive while you are trying to suppress all distracting self-talk and stimuli that prevent you from focusing on an important task. I would imagine that every software developer has been in this situation. You can probably relate to this and recognize it as a time when you are the most susceptible to procrastination.

You will be draining a lot of mental energy in the process. Therefore, unless you can manage to get into a different mental state, you won’t be able to keep yourself doing deep work for long. Probably half an hour is your absolute limit. And then, you can keep trying, but there won’t be much productive work done unless you take a break.

Yes, you can hush the unwanted thoughts temporarily and exhibit some focus. But then those thoughts will just come back. And they’ll keep coming back until you will eventually get tired.

Tolerable low-level boredom can motivate

Low level boredom is a fairly natural mental state that many people have forgotten the feeling of due to constant hyper-stimulation by social media, video games and various other smart gadgets. This state doesn’t feel entirely unpleasant and you can maintain it for a fairly long time. Most of your focus is given to the task at hand, but some of your thoughts still wander. And even though this state is highly tolerable, it still doesn’t feel like it’s the most pleasant thing you could be doing.

The term “low level boredom” is not used universally, but perfectly describes the mental state and distinguishes a mildly unpleasant boredom from an unbearable one. It’s “high level” unbearable boredom that causes your thoughts to wander and makes concentration on important work nearly impossible.

Wijnand van Tilburg from the University of Limerick has done a lot of research on boredom and found a link between it and the desire to do meaningful, but not always pleasant, tasks. He said the following about the benefits of boredom:

“Boredom makes people long for different and purposeful activities, and as a result they turn towards more challenging and meaningful activities, turning towards what they perceive to be really meaningful in life, donating to charity or signing up for blood donations could not have increased the level of stimulation, interest, arousal, novelty, fun, or challenge experienced during the boring activity, simply because the boring activity finished before prosocial behavior was assessed, therefore, we show that boredom affects attitudes and behaviour even after the boring activity, if people have not had the chance to re-establish meaningfulness.” [9]

This characteristic of boredom is precisely why it’s a reasonably good mental state to be in while programming. Unless you are working for some genuinely unethical company, writing code would be meaningful work. but still, the state of low-level boredom is still not the perfect mental state to do coding in.

Because your attention is still somewhat split, some degree of competition between conflicting thoughts still occurs inside your head. And this competition still wastes mental energy. So you will still not be able to maintain this mental state for long. However, this time, you can probably last a couple of hours, because there isn’t a lot of context switching happening in your head.

Experiencing the flow

The state of flow is the most optimal mental state of them all. Your entire attention is focused on the task at hand. Any other aspects of your environment cease to exist to your perception. And there is virtually no context switching happening.

Because the entirety of your focus is on your work, this is by far the most productive state to be in. You don’t see any distractions – internal or external. All you see is the task that you are engaged in. All your mental energy is dedicated toward completion of this task.

This is why, to be as efficient as possible, you need to aim to enter the state of flow.

But don’t worry if the process of getting into the state of flow still seems overwhelming to you. In the further chapters, we will cover specific techniques to make this process as easy as possible. For example, you will learn how to apply microtasks, Pomodoro timers and a Japanese Shisa Kanko procedure. All of these can be combined together to make it easy to fully immerse yourself in productive work.

How state of flow can keep you focused for a long time

While the state of flow is the most productive mental state that you can do deep work in, the amount of focus it gives you is not the only benefit of it. By its nature, the flow state can be maintained for a very long time. Far longer than the state of low-level boredom. This is because you are not wasting any energy fighting distracting thoughts. All of your mental energy is held up in the focus on the task that you are doing. Everything is working in unison.

The science that explains why the state of flow can be maintained for a long time is complicated. But we can use a simple metaphor to figure this out.

Imagine that you have 100 units of mental energy that you can spend at any one time. If you don’t manage to spend it fast enough, it just replenishes itself.

Let’s say you are in the state where you are trying to do deep work while actively trying to suppress any distracting thoughts. The deep work will take 50 units and it burns them slowly – at the same rate as they get replenished. So, if you didn’t have a shortage of mental energy, you could, in theory, keep it up indefinitely. The only problem is that it’s only 50% of your energy that is allocated to solving the problem. So you will probably not find the solution as efficiently as you could have.

programmer productive mental stateBut then distracting thoughts come in. And you need to spend some mental energy to get rid of them. Let’s say it’s 10 units per unwanted thought. But this time, those 10 units burned instantly. But the thoughts keep coming at a fast rate.

When you are shifting the focus between your work and the process of fighting distracting thoughts, you are, essentially, context-switching. And this metaphor is perhaps the best explanation of why context switching consumes so much energy.

Initially, you are fine. You have 40 more units to spend in case any new distracting thought enters your mind. But because those thoughts keep coming back at a fast rate, you quickly run out of spare energy units before you could replenish them.

Now, when the next distracting thought comes, you will have to deallocate 10 units from your actual task and allocate it to fighting this thought. So now, you find it slightly harder to focus. Your productivity takes a nosedive. Eventually, you completely run out of all mental energy units. You can no longer focus and you feel mentally drained.

Even though this is an oversimplification of the actual process, it provides a good model for what’s going on. And it demonstrates why you can’t keep the focus up for long when you have too many distracting thoughts in your head.

Now, imagine that you are in a state of low-level boredom. This time, you have allocated 80 units to your task. Still not optimal, but way better than previously. You will be able to work much more efficiently. And you are still burning your mental energy slowly – way slower than it can replenish itself.

Now, imagine that you still have distracting thoughts. There aren’t many of them. And they aren’t as strong as before. Let’s say you now only need five units of mental energy to destroy each of them. But they still come in at a rate that is faster than the rate you can replenish your mental energy at.

This time, you will be able to hold on for much longer. And your focus will fade away more gradually. But it will fade away nonetheless. This is why, even though the state of low-level boredom is substantially more productive than the distracting state of overactive thought process, you still can’t keep yourself in this state indefinitely. You will eventually need a break.

Now, let’s introduce the flow state. All 100 units of your mental energy are allocated to the task. And there are no distracting thoughts. None whatsoever. The parts of your brain that could have possibly generated those are completely inactive.

Disadvantages of the state of flow

At least in theory, you can keep yourself in the state of flow indefinitely. Unless some significant event brings you out of this state, you will be able to carry on working without losing your focus.

You may have experienced this yourself. Perhaps you were playing basketball and got into a state where virtually every move was perfect. You could evade your opponents. And you can score perfectly with every throw.

But then, something happened and you could no longer replicate the same level of performance in the same game. Perhaps somebody has accidentally knocked into you. Or someone managed to take the ball out of the basket at the very last moment. And that was it after that. You played the rest of the game poorly.

If you can relate to this situation – this is what demonstrates that it’s usually an external situation beyond one’s control that knocks us out of the state of flow. If it was up to us, we could remain in this state indefinitely.

But programming is not a contact sport. Unless you have meetings to attend and emails to answer, nothing will stop you from spending hours upon hours in the state of flow once you manage to enter it.

That’s what allowed Bill Gates to spend all of his waking hours at his office when he co-founded Microsoft. And this is what made Microsoft into the tech giant it is today. That’s what Bill Gates himself said about it:

“I never took a day off in my twenties. Not one.” [10]

If you have ever heard any stories about people falling dead playing video games for several days in a row, this is most likely because they were experiencing the state of flow. Video games are actually a very good medium to induce this state. Likewise, the state of flow is the reason why musicians can play complex symphonies that last several hours.

And the fact that people can stay awake for days on end engaged in the same activity is a very good demonstration of how the state of flow works. The only way to do it is if you kind of forget about your other bodily needs. So, being in this state can actually make you not feel hunger or sleepiness. Imagine how much mental energy is available to your focus when it can be diverted even from the most basic bodily functions!

Akira Yasuda, a notorious game designer and the character designer for Capcom’s famous arcade title Street Fighter 2, was known for his long bouts of extreme hyperfocus. This if, for example, what Tom Shirawa, one of his colleagues, said about him:

“He always slept under the desk. He never went back home.”

And this is what Yoshiki Okamoto, the head of arcade development at Capcom, said about him:

“At one point, [Yasuda] wanted to live a healthy life, so he said, “OK I'm going to drink milk.” So he'd always buy these little packs of milk. He'd be working, and then he'd reach down to his little milk packs and drink them. Around his desk, he had like 100 of these packs. So he'd grab one, shake it, and whenever he'd find one with milk in it, he'd drink it and put it back, without even looking at it.”

Of course, this is an extreme example of using the state of flow. And perhaps only very few people would be capable of maintaining such hyperfocus at the expense of other life activities. But it clearly shows that achieving such a degree of hyperfocus is possible when you are in the flow.

Why state of flow will make deep work enjoyable

But the good things about the flow state don’t end there. It’s actually a really enjoyable state to be in. It may last indefinitely not only because you can allow it to, but also because you wouldn’t want to leave it.

As a matter of fact, humans find many simple things intrinsically enjoyable. But with the amount of over-stimulation that exists all around us, many have forgotten about  them. State of flow brings these feelings back, because it simply switches off all parts of your brain that aren’t needed for the task that you are trying to accomplish.

Mihaly Csikszentmihalyi talks about this phenomenon in his TED talk in 2004, which is called “Flow, the secret to happiness”. In fact, his whole research was motivated by the desire to find out what makes people happy rather than what makes them more productive. But while looking for one thing, he also found the other. [5]

And why exactly something like the state of flow can make our  life enjoyable can be explained in the terms of neurochemistry. There are a number of reward chemicals our body produces that trigger good feelings that we all strive for:

  • Dopamine is produced when we have nearly completed a meaningful task. It generates the feeling of anticipation.
  • Serotonin is produced when we have actually accomplished something significant. It generates the feeling of happiness as a result of it.
  • Endorphins are produced when we have done something substantial and some of our physical resources have been drained in the process. It generates pain relief and relaxation. Runner’s high, for example, is caused by endorphins. [11]

programmer productive mental stateThe problem in our over-stimulated society is that the reward mechanism of our brain is constantly hijacked. We may experience a surge of dopamine while scrolling down the timeline on social media. Not only does it lead us nowhere, but it also prevents us from experiencing quiet pleasures. Those don’t produce the dopamine surge as big as social media does. Therefore we stop perceiving them as something pleasurable.

Because of our modern day lifestyles, when you are trying to do any hard work, it’s probably not as stimulating as your smartphone. And you will remember that. And this is why, under your normal mental state, your work will seem to be relatively boring.

Not so when you are in the state of flow. Nothing exists, but the task you are trying to accomplish. You temporarily forget that any other stimulating sources of pleasure exist. And this is how you can experience pleasure from your work.

When you are making progress – dopamine will kick in. When you have completed something – serotonin will make you feel happy. If you have to think too hard or do something physically demanding – endorphins will prevent you from over-exerting yourself and will help you to keep going.

This is why people who experience the state of flow frequently, start to deliberately seek it. It’s like a drug that the brain seeks out because it wants to feel the pleasurable effects of those three key neurochemicals. And it has many of the same characteristics as being under influence does. But, unlike illicit substances, it actually enhances your life instead of destroying it.

Another thing about the state of flow is that, when the feel-good neurochemicals are released while you are in it, they are released in a balanced way. Addictive activities (like scrolling your Facebook feed) and addictive substances (like illegal drugs) work by releasing some feel-good neurochemicals but not the others. [12] Therefore, even while you feel some temporary pleasure during these activities, you still feel like something is missing. The state of flow makes you feel whole. And there is also something in us that doesn’t make us feel fully happy unless we do something good for both ourselves and others. As Csikszentmihalyi said:

“It happens also, actually, in the most recent book I wrote, called “Good Business,” where I interviewed some of the CEOs who had been nominated by their peers as being both very successful and very ethical, very socially responsible. You see that these people define success as something that helps others and at the same time makes you feel happy as you are working at it. And like all of these successful and responsible CEOs say, you can't have just one of these things be successful if you want a meaningful and successful job.” [5]

The business leaders Csikszentmihalyi has interviewed include Kenneth Derr, a former CEO and chairman of Chevron corporation, Anita Roddick, the founder of The Body Shop and Jack Greenberg, a former CEO of McDonalds.

The simplest way of getting into the state of flow

The state of flow can never be forced. In fact, if you try to force it, you will just end up in a state where you have to actively suppress many distracting thoughts. Not a good state to be in. And, as we covered in an earlier section, trying to force concentration means you will just get yourself mentally drained really fast.

Another point about the state of flow to remember is that it’s not guaranteed to come. Even those who have been experiencing it on a regular basis don’t experience it 100% of the time. But even if you don’t manage to actually get into the state of flow, there are still some techniques that you can apply to make the process of deep work easy. We will cover them in the future chapters. But for now, here are some tips on the things you can do to try and get into the state of flow:

  • The easiest way to get into the state of flow is to just start your activity and stop thinking about the mental state itself. It may come on its own accord in 15-20 minutes. It’s not guaranteed that it will come, but with enough practice, you will be getting into this state easier.
  • When you are trying to enter the state of flow, you can make things easier for yourself by using some tips commonly given to practitioners of mindfulness meditation. When some distracting thought comes, neither act upon it nor try to fight it. Simply acknowledge it in a calm and non-judgemental way and let it go. This too will be getting easier with practice.
  • The choice of activity matters a lot here: it needs to be reasonably stimulating. This is why gamers often experience this state. And so do sportspeople and musicians, who get “in the zone”.  So, for a programmer, writing a boilerplate code or doing a basic project setup probably won’t cut it. But if you need to design some system, find an annoying bug or solve a complex problem, you will be able to enter this highly coveted mental state.
  • The key is to choose a task that is neither too hard nor too easy for you to do. If the task is too easy – you won’t be able to get immersed in it. At best, you will enter a state of low-level boredom. If the task is too hard – your subconscious mind will fight against your efforts to do it. It’s too energy-consuming for it. You will probably be in a very unproductive mental state with a lot of distracting thoughts.

But when the task is just right in its complexity – it can become immersive enough to trigger the state of flow. When the problem is challenging, but is instantly perceived as solvable – your subconscious brain wouldn’t mind. However, because your mind likes to conserve resources, it will switch off those parts of itself that aren’t needed to solve this problem. And this is how you end up in the state of flow.

Over time, if you will practice entering this state often enough – it will become a sort of a habit. You will learn which tasks are best suited to enter this state. And you will build the right neural pathways for performing the right actions. Subconsciously, you will start performing rituals of a sort that will help you to get in the zone.

Rituals to boost productivity are what famous high-achievers are known for. For example, Jeff Bezos, the founder of Amazon, would always spend his morning doing some midless things to allow his mind to wander and get creative. He never schedules any meetings before 10AM in the morning. [13] And here is a ritual that Scott Hanselman recommended on his Twitter to make focusing easy for those who struggle to do it while working from home:

“Here's a tip that my remote team does – When you get up in the morning, if you're willing and able, try COMMUTING to your home office! Go for a circle around your neighborhood and arrive back home to your home/remote office! It psychologically marks the start and end of the day.” [14]

But of course, even with years of practice, it’s not guaranteed that it will happen every time. You don’t control the state of flow. Your subconscious mind does. Plus, you will not always be able to do the tasks that are conducive to this state. But even then, you will build strong habits to enter the state of low-level boredom instead.

Low-level boredom is still better than your default mental state. You can still be really productive in this state. And you can still do productive deep work for substantial periods of time. So, even if you don’t manage to get in the zone, you will still manage to complete your work and do so while being close to your maximum efficiency. You will still be way more productive than most. At the end of the day, very few people consciously build productive habits.

There is perhaps only one disadvantage of the flow state that you should be aware of (other than forgetting to sleep or eat or the fact that you can be jolted out of it by external factors beyond your control). Because this state is only triggered when you are performing tasks of optimal difficulty, you will, over time, need tasks of increased difficulty to trigger this state. When you spend a lot of time working on something – you eventually become good at it. And once you become a master of that activity – the activity becomes much easier.

Now, if you carry on with the same activity, you will just get bored. This is precisely why it’s not uncommon for people to tell you that they fell out of love with the craft they used to enjoy. Maybe you have even experienced this yourself.

In a way, this is a good thing. At least, it’s a good thing for a programming career.

When you keep mastering things of increasing difficulties just to carry on experiencing the state of flow as often as possible, you become better at what you do and have accepted the benefits and pleasure of a growth mindset and continuous life-long learning. And because you spend most of your working time doing deep work while being in the state of deep focus, you become better at what you do at the fastest rate possible.

Just remember this. And keep practicing. Keep working on harder things. You will be a master of your craft and you will never get bored with it. There are of course obstacles along the way; one of the biggest in today’s world we’ve already briefly covered. Now let’s take a deeper look at how social media is intentionally designed to make you form counter-productive habits and stand in your way.

References

  1. Cal Newport – Deep Work: Rules for Focused Success in a Distracted World – Piatkus
  2. Sammy Perone, Elizabeth H. Weybright and Alana J. Anderson – Over and over again: Changes in frontal EEG asymmetry across a boring task – Psychophysiology, volume 59, issue 10, October 2019
  3. Dave Crenshaw – The Myth of Multitasking: How “Doing It All” Gets Nothing Done – John Wiley & Sons
  4. David A. Patterson and John L. Hennessy – Computer Organization and Design: The Hardware/Software Interface. – Morgan Kaufmann
  5. Mihaly Csikszentmihalyi – Flow, the secret to happiness – TED2004
  6. Mihaly Csikszentmihalyi – Flow: The Psychology of Optimal Experience
  7. Julia Silverstein – The Secret to Peak Performance and Optimum Focus – Entity Academy Mag, October 21, 2020
  8. Amelia Hill – Boredom is good for you, study claims – The Guardian
  9. https://www.hanselman.com/blog/programmings-not-for-you-how-about-thinking-be-empowered
  10. Caroline Graham – This is not the way I'd imagined Bill Gates… A rare and remarkable interview with the world's second richest man – The Daily Mail, 9 June 2011
  11. John Medina – Brain Rules, Updated and Expanded: 12 Principles for Surviving and Thriving at Work, Home, and School – Pear Press
  12. Nir Eyal – Hooked: How to Build Habit-Forming Products – Portfolio Penguin
  13. Ali Montag – This is billionaire Jeff Bezos’ daily routine and it sets him up for success – CNBC, 15 September, 2018
  14. https://twitter.com/shanselman

About the author

Fiodar Sazanavets

Fiodar is a senior full-stack software developer specializing in distributed cloud-based ASP.NET applications. He has also built Android apps and PHP websites. Fiodar is the owner of mobiletechtracker.co.uk, where he shares his knowledge of the tech world.