How to Maintain Your Mental Health As a Programmer

How to Maintain Your Mental Health As a Programmer image

Poor mental health is not something that you can easily see or even, sometimes, feel. It's not a tear in a muscle; it's not a broken bone; it's not something that hurts in the way a physical injury does.

Instead, mental health is your thoughts, your mood, your behavior. Because it's intangible, mental health is hard to diagnose and easy to dismiss. But that doesn't make it any less important. On the contrary, good mental health is vital for the overall quality of your life.

If you're a software developer, there's a good chance you work with someone who has a mental health disorder. In the 2020 Stack Overflow Survey, 15% of all respondents said they have some type of anxiety, mood, or emotional disorder.

Programming can be a stressful job because of its tight deadlines, often unrealistic client expectations, and because programmers feel pressure to continuously upgrade their skills. This all generates anxiety, which can ultimately lead to burnout.

That's why programmers need to take good care of their mental health. Here are 4 ways that will help maintain or improve your mental health as a programmer.

Sleep, Eat, Exercise

Enough sleep, a good diet, and regular exercise are the foundations of good mental health. Apart from the well-known and well-documented physical health benefits, these three will go a very long way to maintaining and improving your mental health too.

Mind you, none of these will ever be perfect. Parents might go months without a good night's sleep, pseudoscience and conflicting information make diet notoriously hard to get right, and you'll have days where you'll be unable to exercise.

That's okay. You don't need them to be perfect. You need to prioritize these appropriately, because they're essential and make your life significantly better. If you've reached this point in the article and are not sleeping, eating, or exercising well, come up with a task on how you can improve in that area starting from today.

Practice Feeling Better

When you don't feel well and someone tells you to just “practice feeling better” you might never want to see that person again. But underneath this seemingly conceited advice are two important and practical pieces of advice.

Firstly, practice gratitude. This will come easier to some than to others, but no matter how false it feels, think about what you're grateful for on a daily basis. Smile, even if you don't feel like it, and look around. Do you have electricity? Coffee? Internet? Life on a planet that miraculously hangs in nothingness at just the right distance from a huge ball of flames?

Sounds pretty good, doesn't it? Be grateful for what you have.

Secondly, do what you enjoy doing. If you don't know what that is, make it your mission to figure it out. Play with your dog, go paintballing, meet up with friends, draw the tree outside your window. Whatever gives you joy, whatever makes you feel a little lighter, do that on a regular basis.

Consider Your Thoughts

The brain is an imperfect thing. If you're not careful, it can spin up thoughts that lower your confidence and make you feel unworthy. Impostor syndrome is a typical example of this. They're negative thoughts that are both useless and harmful.

Capture these negative thoughts and parry them with a positive thought. For example, parry “You'll never be able to figure this out” with “You can do this if you put in the hours” or whatever other thought resonates with you. This will be hard at first, but you'll get better as you practice.

There's a bigger point to be made here too. Your thoughts constitute your beliefs and some of your beliefs can be self-sabotaging. Long working hours are a typical example. Even today, long working hours are glorified.

But programming is a creative profession and creativity requires incubation, a fancy word for relaxation. You'll be a better programmer if you're well-rested. So don't feel as if you need to burn the midnight candle because "that's just what it takes." Long working hours might make you feel more productive, but it can lead to burnout, during which you won't be productive at all. Life is a marathon, not a sprint.

Know Where You Have Support

It's okay not to be okay. If you're struggling with a mental health disorder, seek help. You don't have to figure it out by yourself; many people will understand you and help you recover.

It doesn't hurt to know where you can get mental health support, whether that's the CDC in the US, your local therapist, or even, if you're an X-Teamer, the Unleash+ budget for any other type of mental health support.


Good mental health is as important as good physical health. Getting enough sleep, eating well, and exercising are the fundamentals for feeling better. In addition, practicing gratitude and routinely doing things you enjoy will go a long way too. Finally, don't allow negative thoughts to cloud your thinking and know where you can find support if you need it.

Combined, these tips should be a rock-solid defense against the anxiety and stress that tend to sneak into the life of a software developer.

KEEP MOVING FORWARD

Thomas De Moor / health