DEV Community

Cover image for The practice of mindful programming

Posted on • Originally published at on

The practice of mindful programming

This article is about applying mindfulness to the job of a software engineer. If you - like me - love what you do, but are often swept off your feet by a day’s worth of hyper-focussed coding. Or are sometimes stunned by the changes and challenges in the industry, or dealing with the oh-so-common imposter syndrome. Then I hope that some of what I’ll share in this article might allow some relief.

How this all started

In 2022 I had the pleasure of following an 8 week mindfulness program. It was frustrating, intense and humbling, a great addition to the habit I had created in 2021 to spend at least five minutes a day practicing meditation. Of which, human as I am, after reaching a 365 day streak, I lost track of and have been trying to get back to ever since.

Working in an industry that is fast-paced and full of challenges both technical and personal, I quickly realized that I wanted to specifically find out in which way I could apply the practice of mindfulness to my professional life as a software engineer.

On mindfulness

The program I followed is called Mindfulness-Based Stress Reduction (MBSR). And while this might sounds spiritual for some people, it actually is a scientific and evidence-based program and has helped a lot of people cope with stress, anxiety, depression and pain. Without diving in too much detail: it consists of a lot of daily exercises that focus on learning to openly feel what is happening inside your body and mind.

Part of the program are nine attitudes of mindfulness. They provide a roadmap to guide you through the challenges you might face on a day-to-day basis. They helped me find specific elements in my life as a software engineer that I thought could benefit from them. This is why I’ll go through each of the attitudes to explain how I try to practice it during my day-to-day job.

The 9 attitudes

1. Non-judging

When people start becoming more aware of their own thought patterns, so too, will they notice a lot of judgement in their mind. It can be easy to get caught up in opinions, ideas, likes, and dislikes. Both towards others, but especially ourselves. As a software engineer this might manifest itself in thoughts like: “I can’t believe I committed this code with so many mistakes in it”, “Why didn’t I think of that great architecture that my colleague came up with?”, “I really hate working in Redux” or “I should really learn more about that new framework everyone is talking about, but I’m already so busy with work, kids, taking care of family and 2 other courses. Everyone else is up-to-date, why am I always so behind?”.

If I'm experiencing judging thoughts it helps to recognize the thought as a judging thought. I acknowledge them as if I’m an impartial judge: “ah look, another one of those thoughts”, then I take a breath and continue with whatever I was doing. I try not to engage with the thought, as that won’t help me too much. I also try not to judge the thought itself, I just notice it’s there, and move on.

2. Patience

I am a self-taught software engineer. So more often than not I wish I could gain all the knowledge I’m still missing all at once. But some things need practice, and practice needs time. Not to mention that forcing knowledge upon ourselves without taking a rest will do just as much harm as over-exerting a muscle. Nothing good will come of it and there is the danger of burn-out when we extend ourselves beyond our limits.

As a software engineer, when I try to learn something new I allow myself a bit more time than I usually would. As, sadly, I have this inner-belief that I should understand new concepts immediately! I try to accept that things will become clear in their own time. I try to open myself up in a calm way to each moment I am learning something new instead of rushing through.

3. Beginner’s mind

This attitude can allow you the delight of opening yourself up to new experiences. We’re used to doing things a certain way, or we have expectations of how things might, or might not work. Yet it can be eye-opening to try out new solutions, or work with people with totally different experiences than ourselves.

A nice way of practicing this could be to openly ask others how they would have solved an issue you worked on. For example by asking more in-depth feedback on a PR, or by pairing on something with someone who has a lot more experience than you have.

If you are the person in your team with a lot of experience, the latter can be just as interesting to do with one of the people on your team that might still be a junior. Let yourself be surprised by the different ways other people would solve a problem, independent of their years of experience.

4. Trust

When learning mindfulness, a big part is to start trusting your own body and feelings. It can help you to allow yourself to be your own person. Trust allows you to take responsibility over the things you do. And when you learn to trust your own gut feeling, chances are that you will slowly start to build trust in others as well.

For me, this meant noticing when I need something. For example when I need help on solving a problem, or when I have this gut feeling that I need more information before I can properly write code. I work with a team where I feel safe to engage in conversation on how I might think we could solve a problem. This allows me to trust my gut feeling when I might have a good idea. It also means trusting that if someone else has a good alternative, I’ll be able to learn from it and be humble enough to commit to that solution.

It can also manifest itself into recognizing the feeling that I am properly stuck. If my mind and body are screaming that I’m not getting anywhere with a piece of code, it's a signal that it is time to either ask for help, or to take a break. This will be the moment that I probably step away from my work for a bit to do something else that is actually healthy for me. Like eating a snack, taking a walk or drinking some water or tea. Every time I listen to myself in these cases, when I return to my work I’m able to solve the problem.

5. Non-striving

Oof, ok I know I know. This one is complicated. This attitude doesn’t mean you shouldn’t be setting goals in life, or just sit back and not do anything anymore. It’s more about the way that we might tend to approach things. Because it’s a difficult one for me to explain, I’ll start with a quote:

‘…if you sit down to meditate and you think, “I am going to get relaxed, or get enlightened, or control my pain, or become a better person,“. Then you have introduced an idea into your mind of where you should be. Along with it comes the notion that you are not okay right now. “If I were only more calm, or more intelligent, or a harder worker, or more this or more that, if only my heart were healthier or my knee was better, then I would be okay. But right now, I am not okay.”’


For software engineers who are dealing with insecurity or imposter syndrome, this might mean accepting that it’s okay to want to learn new things, and become better at your job, but that at this current moment you are in essence, already good enough for what you're doing right now. This also means that if you need to learn something new, you will deal with any judging thoughts, and accept that needing to learn something new, doesn’t mean that you're not okay right now. This allows you to focus on what is happening in the moment. Which could mean: right now you don’t understand something and that is okay. This is why you're going to learn something new (with patience?), which is also okay.

6. Acceptance

With acceptance we’re allowing ourselves to accept the situation as it is. This also means cultivating acceptance of ourselves. It doesn’t mean that we have to like whatever situation we are in, or whatever we might be dealing with.

For example, let's assume no software engineer enjoys it when they realize they introduced a bug. They might judge themselves (judging), they might feel like they’ll never learn! (patience), they might think this means they are not a good software engineer until they learn to avoid this problem once and for all (non-striving). All of this is fine. All you can do in that moment is notice all those thoughts without judging and accept that right now something is broken.

But with the clarity of this acceptance you can also move forward and see how you can actually start to solve the problem. You should trust that while you might have introduced this bug, you will also find out how to solve it. Whether that means by yourself, or by asking for help from someone else who might teach you.

7. Letting go

The practice of letting go is essential in mindfulness, and I think that a lot of the concepts we talked about before touch upon this attitude a lot. It’s all about holding on to certain thoughts, feelings or situations.

For some people this might mean letting go of the feeling that in order to become a good software engineer, you need to spend all of your free time investigating the latest news in tech because you’re moving towards a burn-out, even if it means that you might then not be able to talk along with people on the bird site anymore. It could also mean taking a breather and working through a piece of old code you need to maintain that you’d rather throw right in the bin, and finding a way to get the work done.

Sometimes letting things go is hard, because it means we need to let go some form of control. But it usually means investing in our personal health when we do it. And it's worth trying out.

8. Gratitude

More and more research points out how beneficial gratitude can be for our health. Practicing gratitude, in whatever way you want, can really compliment the practice of mindfulness. If only because it allows you to focus on something good right now, instead of wandering off in thoughts about the future. It doesn’t mean you have to ignore things that are negative at all. It just means allowing time to think about things you are grateful for, however big or small they are.

I’ve practiced gratitude in a number of ways, and I really think it depends on the person which one suits them best. I’ve written down at least one thing I thought went well each day, or each week. I’ve also practiced talking about two things I’m grateful for and asking others to tell me theirs. Creating a brag sheet is also a form of documenting gratefulness that might work for some. And one thing I really enjoy is that we have a practice of openly thanking people in Slack at the company I work for.

In case you need more examples, here are a few:

  • Thankful for a lovely cup of tea
  • Thankful I finished a 8 week course
  • Thankful it was such a lovely winters day
  • Thankful for having friends or a partner I feel safe with
  • Thankful that the bus was on time
  • Thankful that I ran into a friend in the grocery store

9. Generosity

Practicing generosity could be what you did right now. Maybe you saw the title of this article and thought: “I really want to see if reading this can provide me with any interesting insights”. You allowed yourself the time to investigate something to make you navigate your work-life in a more balanced way. It can also mean practicing any of the above attitudes, investing time for yourself.

It can also mean providing selfless help to others. It definitely doesn’t mean giving unsolicited help or advice. But it could mean stepping in to help someone when they ask for it, and giving them your time. It can mean listening to someone when they want to talk about something they are struggling with, and not giving them advice, but just giving them your attention. Allow others to reject your help, but feel free to offer it. A top-tip is to give friends the generosity of telling them that whatever they are feeling, or going through, is valid. And that it is okay for them to be feeling that way. Something you’ll learn when you practice mindfulness yourself.

We usually say we 'practice' mindfulness because that's what it is: something you practice and become better at over time. But it will always stay a practice, and even those who have done it for years mention that it stays challenging. If you made it this far I really hope something may have been useful or insightful. It felt vulnerable writing this article, but I also think this is a subject that deserves more attention. We bring the best and most productive version of ourselves if we are healthy in both body and mind, and this might help us get there along the way.

In order to write this article, I looked back at my 8 week MBSR training and was inspired by other people talking about the different ways they put their mental and physical health as a first priority. If you’re interested in some of these resources, here is a small list:

Top comments (2)

erinposting profile image
Erin Bensinger

This is a brilliant application of these principles! Thanks for writing and sharing this, Karin.

detzam profile image

when i read the title i thought it was about how to write code while you have in mind the fact that people far more capable or far less capable than you will work on it in the future.