Like many of you , I've suffered from anxiety on and off over the years. From time to time I've been crippled with fear, locked in unhealthy, negative thought patterns that have on occasion rendered me paralyzed, unable to attend to my work effectively and a burden on my relationships.
Thankfully it bothers me way way less these days - there are several practices and resources that I draw on to make sure that remains the case. (I've learned a fair bit over the years about how to work with it, it's one of the main reasons I started sharing at CodingMindfully.com).
I've pondered the relationship between programming and anxiety many times over the years. I've often asked - does programming professionalize anxiety? And if it does, what can be done about it?
A good programmer considers all the different ways something can go wrong in their code. From checking input values, to thinking about UX, to finding the edge cases of algorithms, to being worried about how the next person to read your code might think of it - there’s good reason to worry!
All of which is excellent for your coding skills, but isn’t always much fun when you can’t let go of those worries while away from the screen.
Here's a list of things I worry about on a day to day basis:
- How do I begin to understand this codebase?
- Should I use a fancy data structure here or is an array just fine (again)?
- Why do I never use fancy data structures and algorithms? I'm so average at programming.
- OMG I've just broken production!!! Oh no wait, it's all good...
- Is this merge conflict my fault? Surely not, right? Oh wait... that's totally me.
- Am I ever going to be smart enough that solving this problem feels easy?
- If I write it like this, will it fall over with a bigger dataset?
- What happens if the user doesn't understand this layout?
- What happens if the user puts garbage in this field?
- Is that a good name for this variable?
- Why is this client so questioning of my work?
- Will someone else understand this code? Will I understand this code in a week? A year? (Possibly not!)
- Am I going to survive in this career (18 years later and I still have this one!)
- Does team-mate think I'm an idiot?
I could go on but you probably get the idea! Suffice to say, worrying about what might go wrong is a big part of a programmer's job.
As programmers, making our living or deriving our pleasure from our minds - so it's important to know how it operates. The job of a mind is to keep you alive. Our minds often operate in one of two modes - rehearse or review.
In rehearse mode, our minds prepare us for threats and challenges it anticipates we might face. You can think of this as future-facing worry. It's the mind preparing us to be ready for the worst. This is the source of much of our anxiety.
In review mode, we're running things from the past over in our minds over and over again. The aim of the mind is to try to learn from events that we've experienced, so that we might not commit the same errors again.
Humans have a natural inbuilt negativity bias. This means that we give more mental weight to situations and events we perceive having a negative impact on ourselves - the weighting is said to be 80/20 in favour of negative events.
This negativity bias pervades both our rehearsing and reviewing modes of mental operation.
Our minds are designed to keep us safe, but the price is often a tendency towards worry and anxiety. It's possible that programming professionalises the negativity bias by encouraging us to be hyper aware of what me might get wrong.
It can mean that we, as coders, suffer from anxiety to a degree that isn’t as comfortable as we might like.
So what's to be done? Chronic anxiety can be worth seeking professional help - I've done it in the past, without shame. Along the way I've learned a few things about how to work with my own negativity bias, which I'll share now.
It takes conscious efforts to deal with the negativity bias. It's rooted pretty low down in our psycho-physical system. There's a few things you can do to counter it though.
It turns out your mind can be trained in positive emotional states using a principle called Taking in the Good as explained by Rick Hansen. In this viewpoint, feelings are a skill that can be developed with practice.
The way to do it is pretty straightforward:
- Notice when you're feeling in an enjoyable mood state
- Explore how that really feels in your body and mind - take in the sensations, thoughts and movements of energy
You can do it now by simply remembering your happiest event and tapping into how it makes you feel in your body - let me know how you go.
If you're finding it hard to remember or experience positive emotions, a great place to start is the practice of gratitude. The idea here is to start training your mind to look for positive situations (no matter how small). The more time you spent looking out for things to be grateful for, the less time you have to spend worrying!
It's really easy to start practicing - all you have to do is end your day by writing three things you're grateful for on a piece of paper. It could be something that went well at work that day.
For example, moving a ticket from In-Progress, to Done - this can be super satisfying if you let it be. Or even just getting those pesky unit tests to finally pass!. Or remembering an act of kindness by someone who has been good to you. Or just that you enjoyed a coffee that morning.
Try it for a week and see!
As you'll probably know by now, one of my tools of choice is mindfulness meditation (which helps me detach from the negative thought loops I sometimes find myself lost in).
I find my way out of anxious states a lot more quickly, because I've learned to recognise them as the arose rather than when I'm already deep inside. Meditation also helps me to release stress and tension which also helps.
There's plenty more to read about my story with anxiety here.
How about you? Are you an anxious programmer? What would you add to the list above? And what are you grateful for??
Level up every day
Most of my functions now accept a single parameter of type `object` and many of them return or resolve to a value of type `object` as well. Thanks in part to the _destructuring_ feature introduced in ES2015, I’ve found this to be a powerful pattern...