DEV Community

Cover image for A dev's guide to meditation - part 2
Daragh Byrne
Daragh Byrne

Posted on • Originally published at

A dev's guide to meditation - part 2

This is a serialisation of a guide to meditation for programmers that I first posted over at If you can't wait for the full series to be published, head on over and download your free PDF copy!

How meditation makes you a better coder

There are three main ways that the skills I have learned in meditation directly apply to my coding activities. They are:

  • Increased focus through distraction management
  • Stress management through relaxation
  • Optimising experience through self-awareness

Increased focus
I lose focus all the time. This might sound strange coming from someone who has meditated for a good chunk of his life, but it’s true, and will continue to be true. But I still know that meditation has helped with my ability to stay concentrated on coding tasks for extended periods - which is bloody useful!

Like most humans, I find my mind off-task multiple times a day. There are a couple of major ways I find myself distracted when trying to cut some code.

  • Internal distractions, such as getting caught in a rabbit hole of thoughts or feelings - in particular frustration (sound familiar?), but also anger and shame;
  • Research distractions - a simple query of Stackoverflow turns into a full-blown YouTube binge or a reddit gravity well.

Mediation doesn’t mean I never get distracted. But learning to meditate has given me a better relationship with distraction. In general

  • I get distracted WAY less;
  • I notice it has happened FASTER than I used to, which means I waste less time;
  • I find it MUCH easier to direct myself back onto the task at hand.

All of this means I’m able to devote much more of my productive time to getting what I need to do, done!

Stress management
I’ve worked in some stressful jobs, and some less stressful jobs. The first job I had out of university I once worked a 21hour shift! I got rid of some bugs, but I definitely introduced some more.

Even in the best of environments, it’s possible to push the stress levels to uncomfortable levels from time to time.

There is no doubt - the foggy mind, elevated physical tension and emotional reactivity associated with the condition of excessive stress get in the way of writing solid code. We need to think clearly to code clearly!

Meditation has trained me to become aware of the subtle mental and physical indicators that tell me I’m on the verge of being over stressed. Conveniently, the practices themselves have taught me how to de-escalate my nervous system in a reliable and portable way.

Optimising experience
My overall experience of life has been enhanced and improved by my meditation practice because it has taught me self-awareness.

As a result of this continued study of my breath and my body, I’m more aware of my state of being on a moment by moment basis.

I can tell when I’m feeling anxious, or sad, or happy, or frustrated, or giddy, or distracted. Many times a day I remember to ask myself - how am I feeling right now?

Whatever it is that I’m feeling, I can evaluate whether that state is useful or not, and perhaps choose another way to be in the world. I can optimise my experience to suit the circumstance.

Say I’m pissed with a co-worker or client. Perhaps I notice that anger as a physical feeling of rage, and a desire to lash out.

Knowing this is powerful. I can make a call on how best to use that anger. Lashing out might not be the best thing to do - perhaps a more measured approach might serve my long-term interests better. Because I’m aware of my anger, I don’t have to be controlled by it.

Or I find myself frustrated and disheartened during a bug hunt (who hasn’t been there?). Instead of needlessly persisting or turning on my “inner critic” (you know the voice - the one that says you’ll never be able to fix it), I give myself a break and return to the problem refreshed, or talk to a teammate and we fix it in minutes.

Self-awareness leads to better decisions and a smoother experience of life. It’s a superpower!

How to meditate - the Standard Meditation Algorithm

Meditation utilises a fundamental capacity of the human mind - the capacity to direct the attention - to maintain awareness of the breath and/or the body for a sustained period.

Meditation is a deliberate, intentional act. To meditate, you decide that you will carve out some time from your day.

During meditation, you maintain a mental intention to remain aware of your breathing, or some aspect of the sensory world of your body, as best you can, for the period of meditation.

At the heart of every meditation practice is something I call the Standard Meditation Algorithm. If I were to write it down in code, meditation would look a bit like this (please ignore the potential infinite loop!).



At a high level, what you need to do is:

  • Set aside some time in your day to intentionally practice meditation - typically 10-25 minutes is about right;
  • Deliberately relax the body;
  • Direct your attention towards something - typically we use the breath, or the sensations coming from the body, but there are many other options - we’ll go into this in depth below;
  • Watch how the mind quite naturally resists staying focused (it's crazy in there some days) - it WILL wander, this is 100% expected and you will notice it happening;
  • Restore your attention as the mind wanders - maybe ten times, maybe a hundred, maybe a thousand! The number really doesn’t matter - as long as you remember to redirect your attention back to your meditation from time to time you are meditating 100% correctly;
  • When you emerge from your session, check in with yourself and notice what’s emerged as a result.
Here is the most important thing that anyone will tell you about learning to meditate - it doesn't really matter if it wanders, what matters is that you bring it back. This is so important I’m going to say it again, this time in bold. It doesn't really matter if your mind wanders - what matters is that you bring it back, gently, without self-reproach.

MANY people find this process relaxing, often finding that their focus has improved, or they feel mentally clearer (such important qualities of mind for a programmer).

You can try it right now. Close your eyes, relax your body deliberately with a few sighs or yawns and just focus on the next ten breaths you take - about a minute or so (you can count to yourself mentally).

Just feel where you notice each breath in the body, whether it's fast or slow, deep or shallow, in the nose or in the belly.

Don't worry about getting it right - treat it as an experiment. See how you feel after - perhaps even just a little more relaxed? Maybe, maybe not but be curious. Either way, you just meditated.

Once you're done, you can check in with yourself and notice the effects. Remember I asked you about why you were reading this guide? Does how you are feeling now tie in with that goal?

This paragraph contains maybe the most important thing you’ll ever learn about meditation, so pay attention. This is very important - success in meditation is NOT ABOUT STOPPING MIND WANDERING. The mind will wander, that’s entirely natural and expected. Meditation is much more about NOTICING THAT THE MIND HAS WANDERED and then, gently, restoring focus to the object of meditation itself.

If you do that ten times, great. If you do it a hundred times, great - you still have a 100% record of noticing distraction and getting back on track.

It’s a bit like driving a car - every so often you notice your trajectory and make a little course correction to stay on the road, nudging the steering wheel or altering your speed.

Except what you’re “steering” is your attention. It won’t always stay on your breath or body by itself, so you just gently nudge it back in that direction when you notice you’re off course.

Practicing Meditation

So, enough talk. Let’s get down to the business of meditating. In this section, we’ll introduce two meditation practices that apply the Standard Meditation Algorithm.

The type of meditation we introduce here uses a very fundamental capacity of the human mind - the capacity to pay attention. To meditate in this way is to selectively tune our attention to be aware of a particular thing, and to remember to redirect and refocus our attention as it naturally wanders.

I’ve created a few companion meditations for you to practice with. You can access them at this link.

Here's one of the meditations as an embed. Try it out and let me know how you go.

Stay tuned for part 3.

This is a serialisation of a guide to meditation for programmers that I first posted over at If you can't wait for the full series to be published, head on over and download your free PDF copy!

Top comments (2)

perigk profile image
Periklis Gkolias

Thanks for both guides Daragh.

I have two questions if you could help.

  • Does the hand on the belly helps you being more in control?
  • What are your top3 guided meditation apps/playlists?
codingmindfully profile image
Daragh Byrne

Hey! The hand on the belly is for feedback- so you can feel the belly move. We’re not used to breathing in this way all the time, so it can help!

Guided meditations are quite personal - we all have different tastes in voices and pace and so on. I started out with the mindfulness based stress reduction audios by Jon Kabat Zinn. There are many more available on YouTube and insight timer - it’s worth exploring to see what works for you!