One of my favorite ways to explore mindfulness is to integrate a mindfulness exercise into an everyday activity—washing dishes, driving a car, eating dinner, sweeping the floor. As the Zen saying goes, “Chop wood, carry water.”
Since I spend so much time writing code, I’ve been experimenting with ways to connect mindfulness exercises to daily activities related to programming.
Besides being a way to have a more mindful day overall, practicing mindfulness in proximity to programming can help with many common situations that arise when coding. Writing code is a complex experience—it often requires a high level of focus, and moments of frustration or confusion can often bring up strong emotions and mental cloudiness.
- Getting stuck for hours with mounting frustration
- Frustration when learning new skills or concepts
- Getting addicted to writing code
- The complications of collaborative projects (distraction, communication)
- Getting bored and losing interest in a project or programming in general
Here are a few of the mindfulness exercises I’ve experimented with. Many of them are simply ideas to start from, so if you try them please experiment with them and let me know how it goes!
Start each coding session with a few minutes of sitting meditation (Headspace can help) and end each session with a few minutes of walking meditation.
Pre- and post-commit breathing
Take three deep breaths before and after each Git commit and Git push.
Pull request gratitude/loving kindness
When creating or reviewing a pull request, take a few deep breaths and repeat a mantra that is focused on gratitude and kind speech. Here are some ideas that are loosely based on mantras from Thich Nhat Hanh’s book, Work. I would recommend coming up with your own, formal or informal, to match what you prefer!
When reviewing a pull request:
Reviewing this code,
I am grateful to those that wrote it
and for the tools that were used to write it.
May this code bring health, peace, and well-being.
When creating a pull request:
Code can travel thousands of miles and affect many people.
I vow to write code mindfully and lovingly. May this code create mutual understanding and peace.
When ending your work for the day or switching to a new task, review each open tab in the browser and text editor and close each one that you don’t need while taking a breath.
Naps and Food
Rest when you’re tired, eat when you’re hungry, drink when you’re thirsty.
I’ve found that daily writing (such as 750words.com) is one of the best mindfulness exercises and maybe helpful to integrate into a daily routine.
If I try any other exercises, I’ll update the list here. Let me know if you try any of these and how it goes!
Late Night Code Club Newsletter
It’s midnight. You’re huddled in the restricted section of the library, eyes glued to powerful tomes—Creating Killer Websites! Resilient Web Design! The Pragmatic Programmer! You get a missive from your co-conspirators in the Late Night Code Club—another night of adventurous learning is about to begin.
If you enjoyed this post and want to read more like it, I’d like to invite you to join the Late Night Code Club by signing up for the newsletter—it’s a programming education newsletter all about learning and teaching programming. We’re exploring new approaches to learning and teaching, code as a creative practice, and programming as part of an interdisciplinary education. In each newsletter you’ll receive updates about new posts as well as other resources and ideas all about learning programming! It’ll be short, interesting, and encouraging for learners and teachers. See you there!
Published 5 September 2017
Kevin McGillivray is a web developer, writer, and teacher from Wisconsin. He writes about creativity, mindfulness, code, and tea.