Why You Should Practice Mindfulness Meditation as a Programmer

On Instagram and Twitter, I recently created polls where I asked how many of you guys meditate, and only about 30% voted positively. This number should be much higher, considering how many benefits mindfulness meditation provides, especially for people who use their brains as much as programmers. If done regularly, meditation can drastically reduce stress, frustration and overwhelm in your life and therefore make you happier and more productive. It improves your memory and learning capabilities and keeps your brain young as you age. Besides that, it can also make pretty much any activity more enjoyable, not only coding. To benefit from meditation, the field you work in or what else you do in your life doesn’t matter, so this post is directed to everyone. I just themed it to programming because that’s what 99% of my visitors do.

But first of all, I want to say that this post is not spiritual, and we are not trying to connect our soul to the universe or leave our body or stuff like that. This post is about the scientific side of meditation as a practice to train our brain. I am a very skeptical person and before I spend 30 minutes of my day sitting with my eyes closed (you don’t have to do that much), I better be sure that there are some reliable studies backing up the promised benefits of this practice. Just opinions and belief is not enough, I wouldn’t do meditation if there was no scientific evidence of its effects. Luckily, we don’t have to search very long for these studies, because there are plenty.

We will not look at meditation from a religious point of view here, but it can be part of religious practice. If you already do meditation as part of your prayers, that’s great. But if you find that what I describe here is much different from what you’re currently doing, you might want to add it as another practice to your day. Mindfulness meditation has its roots in Buddhism, but I won’t go into detail about the history here. If you want to know more about it, I encourage you to search for it in Google.

Ok, so what does meditation do and how does it help us?

Simply put, mindfulness meditation trains your brain to stay focused on the present moment with a non-judgmental attitude.

Being mindful means observing your thoughts, emotions and sensory input on a moment-to-moment basis without labeling them as good or bad or getting caught up in them.

Ok, why is this helpful?

Well, a lot of our problems are caused by a distracted mind and uncontrolled thinking. First of all, it obviously makes you very inefficient. For example, when you try to focus on a task like building a new feature into your app, but your mind constantly keeps wandering to other problems, like a looming deadline or a mean thing your coworker said the other day, you waste your valuable time and brain energy because you jump back and forth between unrelated topics. It has long been known that multitasking is very inefficient and this is also true if the switch between tasks only happens in your head. No matter if these unrelated problems are important in the grand scheme, it just isn’t helpful to ponder about them in the middle of doing something else. Wouldn’t it be much better if you could just stay focused on the task directly in front of you and only switch to something else once you’re done? Personally, I find nothing more exhausting than trying to concentrate, for example when reading the documentation of a difficult API, while my mind constantly keeps wandering to something else and I always forget what I’ve just read a moment ago.

But even in our free time, when we’re not currently working on any difficult tasks, we often ponder over problems, for example when we are in the company of friends or when we try to enjoy leisure activities. How often have you eaten something and realized 10 minutes later that you didn’t really pay attention to the taste because you constantly kept thinking about something else? How often have you tried to enjoy a good book just to realize at the bottom of the page that you have no idea what you just read? Another time when people tend to ruminate is when they go to bed and just want to relax and go to sleep. In so many different situations, rather than enjoying the moment, our mind is focusing on unrelated problems or already thinking about the upcoming day. Research has shown that we are the happiest when our thoughts align with what we are doing in a given moment. When you’re brushing your teeth, you’re happier when you’re not already thinking about your workday ahead. This is also the case if what you’re doing right now is boring or unpleasant. So when you’re writing on a super boring coding task, you’re happier if you’re thinking about writing this super boring coding task rather than about laying on a sunny beach, even if the sunny beach seems like the more desirable situation to be in.

Another thing that robs us a lot of energy and makes us unhappy is our reaction to problems and adversity. To keep it programming related, let’s say for example that you’re trying to build an app and (inevitably) run into a bug that is hard to solve. This is a challenge, but from an objective point of view, the situation is not terrible. First of all, you will learn something in the process and get a little bit better at programming, so it’s a learning opportunity. Second, encountering bugs is an inseparable part of writing software, it happens to every programmer regularly. Even if you wish the problem wasn’t there, that doesn’t make it go away. You have to deal with it anyways. Where stress really starts to build up, is in our reaction to these problems. When you start thinking about how much time this is going to waste, how you could already be done with your task by now, or when you start asking yourself if you will ever find the problem or if you are too stupid for programming — those are the unhelpful thoughts that build a second layer of stress on top of the first layer and unnecessarily waste energy that you could otherwise use to find a solution. This “stress about being stressed” not only makes problems seem bigger than they actually are, it is also what makes people unhappy and gets them burned out. Your mind creates your reality, and without your conceptual framing around the bug being bad and this task being a chore, it would just be part of your day like any other piece of code you write. Maybe you would even enjoy it. In both situations, you are sitting in a comfy chair, looking at a screen inside a probably warm room while trying to figure out what to write next. The raw sensory input is pretty much the same, but your interpretation of the situation is different. Again, mind wandering is the root problem here. Without your thoughts constantly reminding you how much your situation sucks, it would cease to suck.

Suffering starts when you wish that the situation you’re currently in was different from how it is right now.

Suffering is your resistance to the present moment. There are ups and downs in life, but we reinforce the subjective unpleasantness of these downs with our own thoughts. This is even true for physical pain. The next time you have a headache, try an experiment and just drop all your thoughts and judgment about it for a moment. Try to forget how much the pain sucks, how badly you want to get rid of it, how long you already had it or how much longer you have to endure it. Try to pretend that the past and future don’t exist, breathe, close your eyes and just focus on the raw sensation for a bit. After a while, you will notice that it doesn’t feel that bad anymore and the pain turns into a more neutral sensation. The pain is still there, but by accepting it, it seems to cause less psychological suffering and turns into something that just is. For the average brain this will only work for mild headaches, but for a brain that is trained in meditation and mindfulness, this would even work for more intense pain, like the spectacular case of the burning monk showed.

Your mind shapes your daily experience and your life quality more than what is happening to you, like external factors or even physical sensations like pain. This is why some people thrive under horrible life circumstances while others are unhappy even if they seem to have everything. Happiness is a skill, not something that happens to you. Unfortunately, mind wandering, uncontrolled thinking and worry — the traits that make us so unhappy — are very human tendencies. We constantly tell ourselves (often unintentionally and without noticing) why we have every reason to be angry, sad, frustrated, bored, hurt, scared or generally unsatisfied and this way artificially keep these emotions alive way longer than their natural lifetime. As most of our bad traits, these negative tendencies have evolutionary reasons, because they kept us alive in primal times when the world was a lot more dangerous and resources more scarce. But in today’s society and with our life circumstances, these constant negative thoughts are an overkill and not timely anymore. Another problem is simply the information overload that we are exposed to nowadays and to which our brains didn’t have enough time to adapt. However, knowing about this problem is not enough. If you don’t train your mind, every thought will just pull you out of the present moment and become your immediate reality as soon as it pops into your head. The only way to get this under control is through mindfulness practice. This is where meditation comes in.

There are different forms of meditation and it can also be combined with exercises like Yoga or Qigong. In this post, we will talk about what I think is the most common form of meditation, at least in the west: mindfulness meditation while sitting down with your eyes closed. Nothing fancy here and you don’t need anything to start, besides a chair and maybe some earplugs if you live in a noisy environment.

And it works like this:

  1. Set a timer for how long you want to meditate. 10 minutes is a good amount to start.
  2. Sit down on a chair in a comfortable position with your back upright and your hands resting on your legs. There are other meditation poses, but this is the easiest to start with.
  3. Relax your body and close your eyes.
  4. Start focusing your attention on your breath. Don’t try to breathe in a certain way or overanalyze it. You can take a few deep breaths at the beginning, but after that, just breathe naturally and pay attention to how it physically feels when the air flows into and out of your nose.
  5. Inevitably, your mind will start to wander. You might start thinking about what you will eat for lunch or how to solve that one coding problem you’ve been working on all day. That’s totally normal and will always be part of your meditation exercise. When this happens, notice the thought, but don’t judge it. Don’t label it as good or bad and don’t be annoyed by it. Just calmly bring your attention back to your breath.
  6. Repeat step 5 every time your mind starts to wander (which will be often) until your timer rings.

This is what meditation is all about. There is no magic or Jedi mind tricks involved. We simply train our mind to not get carried away by every little thought that comes up. And as I explained earlier, being lost in thought is the main reason for unhappiness, exhaustion and mental suffering. Focusing on your breath anchors you to the present moment, and every time you bring your attention back to your breath after it wandered off to a random thought, you strengthen exactly this: focusing on the present moment and letting the thought pass. It is literally like a gym workout for your brain. The same way you can strengthen a muscle by lifting weights repeatedly, you can also strengthen certain neuronal connections in your brain that then make you better at doing certain things. When you try to learn how to juggle, you slowly build new connections that make you better at juggling. You start out really bad, barely able to catch a single ball. But over the weeks and months, it becomes easier and more natural, until eventually, you are really good at juggling. It’s the same principle with meditation. When you practice focusing on the present moment, you steadily get better at focusing on the present moment. This actually makes certain parts of your brain grow denser. When scientists scan the brains of regular meditators, they find increased gray matter in different areas that are associated with enhanced senses and less mind-wandering, better executive decision-making and emotional regulation, but also with improved learning and memory processes and more empathy towards others. Some of these brain parts, like the frontal cortex, usually shrink with age, but 50-year-old meditators had the same amount of gray matter there as 25-year-olds. In other words: meditation keeps your brain young, which is especially important for us programmers who need to stay sharp as we get older in order to keep up with the latest tech. The gray matter of meditators’ brains decreased, however, in a part called the “amygdala”, which is responsible for stress responses. A smaller amygdala means less perceived stress and less anxiety, so that’s a good thing. If you wanna read more about it, here is an interview with one of the researchers that conducted several popular studies on meditation with a summary of the findings. Significant results were found in untrained meditators within 8 weeks of an average of 27 minutes of meditation per day. However, you can also do less than that and just get the benefits a little bit slower. And of course, you can do more to accelerate the effects.

By regularly practicing meditation, you’re not just merely changing the way you think. You improve your brains hardware the same way you increase RAM in a computer to make it handle a high workload more easily.

Mindfulness meditation doesn’t prevent any unpleasant thoughts or emotions from ever coming up again, but it lets you take a more neutral stance, without labeling them as good or bad all the time and without identifying with them. It lets you take the position of an observer of your own mind. You simply notice and accept a thought or feeling when it comes up, and then you let it pass. An angry thought accompanied by some sensations of flushing and tension doesn’t mean you have to be angry. An increased heart rate and sweaty palms together with some anxious worries don’t mean you have to be anxious. They are just internal voices and sensations, they don’t define what you are in this moment any more the voice of a stranger or a warm temperature can tell you what you are. You don’t get caught up or identify with them, but you also don’t wish them away. This is what is meant by having a non-judgmental attitude to the present moment. Similarly, you will find that the same amount of physical discomfort and pain (for example when you do an exhausting exercise), while having the same or even increased intensity, will feel less unpleasant (like in my headache example earlier).

However, being mindful doesn’t mean being apathetic. It doesn’t mean not caring about anything anymore or giving up on your goals. When you are in a suboptimal situation and you can change it, then you should try to change it. If your boss wants you to implement a new feature from which you know that it doesn’t make any sense and that it will just cause problems, then you should tell him about it. It is the circumstances that you can’t change or which you consciously decided not to change, that you should accept unconditionally. If you think that this feature should be implemented, because it’s the right thing to do at this point, even if you are annoyed by the task, then any further mental resistance to it (ie. thinking about how much it sucks) is futile and almost crazy.

We don’t try to stop thinking altogether — after all, we need thoughts to function in this world — and we also don’t try to suppress negative thoughts. We just learn to observe our thought stream from a certain distance and then make a controlled, calm decision about our next action. We use our mind as a tool, rather than getting controlled by it. If a thought is helpful, you can execute on it. The solution to a bug is a thought that you probably want to investigate further, but not a sudden memory about that moment 2 weeks ago when you did something embarrassing. Most thoughts we have throughout our day are simply not helpful (and often even harmful), so we have to train to choose which ones we actually pay attention to. As programmers, we are exposed to an overload of information every day, and this inner distance helps us keeping this input under control. Being mindful is often compared with being in the middle of a storm (your thought stream) versus observing the storm from a safe place, like from behind a window (being the observer). This way you can really focus on what is in front of you, stay calm in difficult situations, and solve problems with patience and without feeling mentally exhausted at the end of the day. It also lets you enjoy things more because you experience every event in your day on a moment-to-moment basis with your full attention and accept them as they come. When you get more mindful in your day to day life, you will notice that not everything around you has to be perfect in order for you to be happy.

There are a lot of indirect benefits that result from this whole concept of non-judgmental awareness:

Since you become able to endure more discomfort with the same or less amount of subjective unpleasantness and suffering, you can learn more and faster. As I explained in my blog post about deliberate practice, effective learning comes with a fair bit of struggle and frustration. With mindfulness, the learning process will still be difficult and confusing at times, but it will feel more natural and less stressful.

By being less emotionally reactive, you also become less moody and therefore more likable by your coworkers and anyone else around you. The sensation of anger, for example, only lasts for a couple moments after something happened that made you angry. The only way for you to stay angry after this is if your thoughts are constantly feeding this emotion. This means, the only reason that you ever stay angry for more than a few seconds, is because you’re thinking about reasons to be angry. Otherwise, it’s just a sensation to be noticed and then let pass.

By distancing yourself from your emotions this way, you will also more easily beat procrastination, because procrastination is usually caused by mild negative emotions, most commonly by a little bit of anxiety about the difficulty and size of the upcoming task. When you’re mindful, you can recognize this emotion and still realize that you don’t have to act on it (and procrastinate), but instead make a conscious, controlled decision. The same is true when you are in the middle of a task and have this sudden urge to grab your smartphone or switch to Facebook. Simply be aware of the urge, notice how it feels and then let it go. Mindfulness puts a little bit of room between the impulse and your reaction to it, in which you can consciously decide to act differently. The same way it can also help to break pretty much any other habit, like bad coding habits. Let’s say you tend to copy paste code without understanding what it actually does. You might do this instinctively, without much thought, or maybe out of laziness, but again, being aware inserts this little space between your intuition and your actual decision and helps you hit the brakes and act differently.

Mindfulness is also closely related to the “Flow state” (the phenomenon which gave Coding in Flow its name). The Flow state (also called “the Zone”) is this joyful experience that can happen when you are fully immersed in an activity. You can read more about it in this blog post. Flow happens when you give an activity your full attention, and mindfulness trains your brain to direct its attention, so it totally makes sense that you also get into the Zone more easily. The best thing is, that the kind of activity doesn’t really matter. You can reach a Flow state not only while doing something exciting, like surfing or playing your favorite video game, but also while washing the dishes or working on a difficult coding problem. By training your attention, meditation can help you get more intrinsic pleasure from everyday tasks. You don’t always have to do your favorite leisure activity to enjoy what you’re doing. You just have to train your brain to be able to enjoy more things.

Treat meditation like a gym workout. You won’t reap all the benefits immediately, just like you don’t get super strong after the first day in the gym. But you will notice some effects after your first session and get a glimpse of what it feels like to be more present. This feeling will gradually increase over the weeks, until you suddenly realize that you don’t get frustrated as easily as you used to, that certain things just don’t bother you anymore and that you are now able to enjoy the little things more. Mindfulness is a skill, and as with most skills, consistency is much more important when it comes to learning than infrequent, big sessions. You can start with 10 minutes a day, which can actually be quite difficult in the beginning. Do it in the morning, because then you prime your brain for the upcoming day and it’s also less likely that you skip a session or fall asleep in the middle of it. You can increase the duration when you feel ready, but really try to do it every single day. I think 20 minutes of focused meditation per day is a good goal to strive for and something that most people can fit into their schedule. However, that doesn’t mean that 10 minutes are not effective and it also doesn’t mean that you can’t go higher to accelerate the effects. Take a look at the instructions above again to see how to meditate.

Also, there are different forms of meditation and other anchor points you can use than the breath. If you want to know more about that topic, you can find a lot of information on Google. There are also tons of books about meditation, but I can’t recommend one, because I haven’t read any yet.

I am interested in your opinion. Do you do a form of meditation? Maybe in combination with Yoga or some other exercise? Maybe as part of your religion? Do I have any Buddhist visitors? Let me know in the comments below!

11 thoughts on “Why You Should Practice Mindfulness Meditation as a Programmer”

    • Wow, 1 hour! I do 10-15 minutes in the morning and to be honest I hate it :’D I just do it because it’s very healthy and it’s a good way to start my day. I love lifting weights tho.

    • Nice! I am happy I could make someone give it a try!
      I started getting more deeply into this topic and bought a great book called “The Mind Illuminated”.

  1. Very insightful read. I struggle with ADHD and I use meditation as a means of slowing my mind down whenever I feel overwhelmed. I meditate traditionally, such as sitting and breathing, and also through long cardio workouts. 30 minutes on the elliptical or a bike does wonders. Happy to know others share the joy of meditation!

    • Nice! I am happy that meditation helps you! I actually just started reading a very good book on that topic, called “The Mind Illuminated”.

  2. You should take it to the next step and start to practice “Vipassana”. It’ll be the best decision of your life. It’s so logical and scientific.

    • Yea I actually now follow a book called “The Mind Illuminated” which, as far as I know, teaches a mix of “Vipassana” and “Samatha”. I’ve really committed to meditation since I wrote this post.

  3. I practice soto-zen meditation since over 10 years and can only advise everyone to do something similar. Without meditation you’re brain won’t defragment properly-like a harddrive it will become scattered and performance will drop, sleep patterns will be filled with loops and objects and garbage that ceeps you from sleeping 👎

Comments are closed.