Sleep Apnea, Insomnia & Software Engineering

Sleep Apnea, Insomnia & Software Engineering: How Getting a Good Night's Sleep Make You a Better Programmer

Sleep Apnea, Insomnia & Software Engineering

Introduction

There's often a strong stereotype among programmers that many of us stay up late into the night, working on our latest project or trying to debug some code. While there may be some truth to this, it's important to remember that getting a good night's sleep is crucial for our productivity, mental health, and overall well-being.

Whilst I've been studying at university and working in the industry both full-time, as well as balancing my other commitments, I've often found myself working the most effectively during the night when my brain would become more alert and focused. This habit snowballed when I started my own startup and was working on numerous projects at once.

However as my workload increased, I started to experience the effects of a lack of sleep more and more. I was constantly tired, my concentration was poor and I was getting sick more often. It wasn't until I started to realize I was struggling to solve or recall simple problems that I realized I needed to change my habits - Sleep was no longer something I could sacrifice for my work.

My Journey

I began by improving my sleep hygiene. I wasn't very disciplined about my sleep schedule and often stayed up late working on projects, writing down startup ideas, and spending time chatting with people in different timezones. I knew that to improve the quality of my sleep, I had to improve my sleep hygiene and stick to a consistent schedule.

I first ensured I was only using my bed for sleep and not for thinking, studying, or working on projects. This was important for me to adopt as I often spent many hours tossing and turning in bed, thinking of my next task or deadline I had to meet rather than trying to use it as a place to sleep, which often led to me staying up late worrying about things I had no control over. I initially struggled to get used to the new schedule but eventually, I was able to stick to it.

Another important habit that I wanted to adopt was ensuring that I was getting at least 8 hours of sleep a day. For me this meant back cutting on optional events such as hackathons and lengthy meetings from my club that I didn't need need to attend, focusing on my sleep in this case over other commitments was a hard decision that took a lot of time and willpower for me to get used to, without feeling guilty.

I also started to pay attention to what I was eating, I made sure that I was eating at least 2 hours before bed so that my body had time to digest the food. I also made sure that I was exercising before bed, this helped tire my body, swap my mind's focus to something less stressful as well as further relax my muscles. Additionally, by taking warm showers prior to sleeping I was also able to assist my circadian rhythm to know that it was late and time to sleep, the change in temperatures from the hot shower to the cold outside helped boost this. Another habit that assisted with this circadian rythm was also putting my electronic devices away at least an hour before falling asleep, this habit was equally as important as blue light can dramatically affect your body's ability to naturally release melatonin.

Lastly, by cutting caffeine out of my diet as much as possible, I was able to significantly improve my mood and eliminate my dependency on the golden liquid. I used to drink at least 3 coffees a day, and after a while, I realized that this was having a negative impact on my health, I would feel stressed, and anxious, and my body would always feel physically fatigued. After a few days of removing caffeine, I started to feel a lot better, my anxiety levels significantly dropped, and I started crashing at the end of the day less and less. This was a massive difference, and I started to feel a lot happier without caffeine in my system. I only have the odd coffee now, and if I do decide to have one, I make sure it is decaffeinated.

The Issue

Whilst all these changes helped a bit and ultimately improved my quality of sleep, I was still waking up with severe brain foggy, migraines, blurry vision as well as still being extremely exhausted during the day. I was struggling to concentrate at work, my productivity had significantly dropped and I was starting to feel depressed. This was having a massive impact on my life, I was struggling to function as a normal human being and my quality of life had deteriorated significantly. I knew that something was wrong but I had no idea what it could be, I was doing everything that I could to improve my sleep but nothing was working.

It was only when I went to see my GP about something else that he asked me about my sleep and that’s when I finally got a referral to a sleep clinic. After a few tests, it was confirmed that I had obstructive sleep apnea, a condition where your breathing is interrupted during sleep. Regardless if I slept for 8 hours or 12 hours, my quality of sleep was poor and my body wasn’t getting the rest it needed. At this point, it wasn't me doing something wrong, I needed treatment in order to improve my sleep and my health.

Whilst it was sad and scary to realize when sleeping I would have to wear a mask that would help me breathe. I was so grateful to finally have a diagnosis and to finally know what was wrong. I was started on treatment, and finally, after years of struggling, I was getting the quality sleep that I needed. My migraines, brain fog, and fatigue slowly started to disappear, and I was feeling like myself again.

Whilst it was very hard starting out for the first 2 weeks, I was not able to sleep at all throughout the night with me being focused and scared by the machine. After a while, however, it became more natural, and I now use it every night without any issues. I’m so grateful that I finally got a diagnosis and treatment, as it has improved my quality of life significantly.

If you’re struggling with sleep, it’s important to see a GP as they can rule out any other potential issues and refer you for further tests if needed. Sleep apnea is a serious condition that can have a significant impact on your health, so don’t ignore the signs and get help as soon as possible.

Below I've written a small diary recounting my experience with sleep apnea in the hope it will help others who may be struggling.

Diary

Day 1

I finally got my diagnosis of sleep apnea today after years of struggling with my sleep. I was relieved to finally have an answer and to know that there was a treatment that could help me. I was started on a CPAP machine which I will need to use every night to help me breathe.

I’m so grateful to finally have a diagnosis and know what was wrong. Whilst I don't like the idea that I'll have to wear a machine whilst sleeping, it is good to know that there is something that can help me. I’m also feeling more positive about the future and how things will improve now I've been diagnosed.

The sleep that night however was terrible. I felt like I was struggling to breathe, and I had to keep the lights on as I felt very unsafe. The low-pressure setting on the machine plus my nose being constantly blocked made it feel like I couldn't breathe. I slept very poorly that night and woke up feeling exhausted.

Day 2

I woke up feeling exhausted again and wasn't looking forward to another night on the machine. I decided to try and make the best of it and started to research more about sleep apnea and how to make the treatment more bearable.

I found some helpful tips online and decided to give them a try. I increased the pressure on my machine and that made a big difference. I also started using a saline nasal spray to help with my nose being blocked.

I had a much better night's sleep and woke up feeling more rested, it was still horrible with me sleeping maybe a total of 1 to 2 hours, and I'm still not used to the machine, but at least I'm getting some better quality sleep.

Day 3

I was really struggling today. I felt so tired, and my head was pounding. I tried to take a nap, but I just couldn't drift off. In the end, I just gave up and watched TV for the rest of the day. I went to bed early, but I just couldn't get comfortable. I tossed and turned for hours before finally falling asleep. I woke up a few times during the night, but I was so tired I just went back to sleep.

Week 1

I'm a week into my treatment and I'm slowly getting used to the machine. I'm still not sleeping through the night but I'm getting more rest than I was before.

I'm starting to feel the benefits during the day too. I'm not as tired and my head is clearing. I'm even starting to feel more motivated to do things.

Week 2

I'm feeling much better this week. I'm sleeping better, and I don't feel so tired during the day. My head is also much clearer.

I'm starting to feel like my old self again. I'm more motivated and I'm getting things done. I'm also starting to feel more energetic.

Week 3

I'm still feeling good this week. I'm sleeping through the night and I'm feeling more energetic during the day.

I'm starting to feel really good. I'm back to my old self and I'm feeling more motivated than ever.

Week 4

I'm still feeling great. I'm sleeping through the night and I have loads of energy during the day.

I'm so glad I decided to get treatment for my sleep apnea. It's made such a difference in my life!

Conclusion

Whilst my first week was tough, I'm glad to say that I'm now on the road to recovery. I have so much more energy during the day, and my sleep quality has improved dramatically. I would encourage anyone struggling with fatigue or poor sleep to go and get checked out for sleep apnea, as it could make a world of difference.

I also recommend that anyone struggling or just starting out to join a community like the one at cpaptalk.com. It's been invaluable for me to be able to talk to others who are going through the same thing, a support system is essential! Especially when you haven't been able to sleepin 3 days...

Additionally for more information regarding sleeping patterns, CPAP machines, and how to handle CPAP-induced insomnia I strongly recommend reading the article "Adventures in Hosehead Land" by RobySue. It was one of the biggest reasons I was able to stick with my treatment and not give up.

For those struggling with sleep apnea now and thinking of giving up, please don't. Sleeping with the machine definitely sucks, especially in the beginning. But, it is so worth it to feel normal and have the energy to get through my day. If I can do it, you can too!