Coding in Your Sleep?

Billy Helm
6 min readOct 14, 2020

Most of us have been dreaming in our sleep since we were little kids. Sometimes it’s the most wonderful out of body experiences while other times it’s dark spooky nightmares. Hopefully the good overcomes the darkness and you wake up in a good mood. That is until coding boot camp starts and you're waking up in the middle of the night in a frantic trying to remember the proper syntax for a for loop. Don’t worry you are not alone, it is a common problem for students to dream about their code when they start a boot camp. This blog is going to show you why your dreams are important and what you can do to get back to the happy sleep we all want.

Patrick’s First Week of Boot Camp

Is Sleep Even Important?

Sleep has long been a researched topic in the field of medicine and there is overarching evidence that shows shorter amounts of sleep can lead to dangerous diseases such as heart disease and Alzheimer’s. There is also evidence that it puts you at a higher risk of obesity and overall can lead to a shorter life expectancy. So why would you ever even consider not getting your full 8 hours of recommended sleep? Well in short, s**t happens and life doesn’t always go as planned. Sometimes you end up sacrificing sleep to get important tasks done or to help people you care about. When you do sacrifice your sleep you are also sacrificing time in REM sleep. REM sleep is very crucial to your body's recovery after a long day. This REM sleep is also where all the dreams happen. Maybe if you’re lucky you can even go into a dream within a dream all while still dreaming…..

South Park Inception

So What Does Dreaming Do Then?

Dreams are cool and all but what can they actually accomplish you might ask. When I dream about my day or things I wish will happen in the future can it really have an impact on me? According to the doctors at U.C. Berkeley, the REM sleep and dreaming are very important and can almost be a self therapy after a long day. REM sleep is the only known time in a person’s life where the “brain is completely devoid of the anxiety-triggering molecule noradrenaline.” The scientists were able to link dreams as a way to calm one's nerves especially after being “triggered” by emotional images. After sleeping the doctors would bring up the same emotional images and patients would be less disturbed by them. Patients were not only taken for their word, but it was all done within an MRI scanner so doctors could see emotional responses of a patient's brain. So BOOM, sleep and dreams are both important so how do we get our dreams back?

Give Me The Dreams

One of the biggest factors in how well you sleep is what you put into your body. If you’re a big coffee drinker the first thing you should do is consider decreasing the amount of caffeine you’re drinking especially in the afternoon. The caffeine can block important chemicals in your body that makes you sleepy at the end of the day. Alcohol is another factor that greatly affects your sleep. While everyone loves a good beer while watching the football game a few glasses of wine with a fancy cheese board, moderation is key. If you still have alcohol in your system when you fall asleep it can significantly impact the quality of sleep you get. It may be really easy to pass out after that 10th crispy boy but you may never even get to the REM phase of sleep that night which means no dreaming at all. While this may sound good if you want to get rid of your coding dreams, it won’t help you recover at all and you will just wake up stressed more than ever the next day of coding boot camp.

While caffeine and alcohol may be bad things to put in your body if you’re trying to get more sleep, there are plenty of good things you can eat as well. Magnesium is sometimes referred to as the anti-stress nutrient and is found in many foods we eat. In particular, magnesium is good at promoting the deep REM sleep which is where dreaming happens. In order to promote this dreaming state, you can start by eating more magnesium-rich foods like nuts, seeds, whole grains, and green leafy vegetables.

Watching what you put into your body is important, but sometimes people forget that you have to take care of your body physically as well. Regular exercise has been proven to make it easier to fall asleep as well as hit the REM sleep and have better dreams. Getting regular exercise doesn’t mean you should start training for a marathon, just get up and be active. Even something as little as a 15-minute walk every day at breakfast, lunch, and dinner will make a difference in the way you sleep at night.

Removing distractions is the next step to help get better sleep. If it is possible it’s always good to keep your sleep space and workspace separate. Try not to leave the TV on or any bright lights. A darker room will make it much easier to fall asleep. The biggest problem especially for the younger crown however is your cellphone. One quick scroll on Instagram can quickly turn into online shopping for a new swimsuit for the next hour. When it’s time for bed put the phone down and put it in do not disturb mode. The beauty of do not disturb mode is that it can keep your phone from buzzing all night long and can default to go back to normal at a set time, say 7 am. If you’re ever worried about getting emergency calls you can even set it up to allow calls or texts from certain people to still ring.

The last step in getting better sleep is to be relaxed when going to sleep. This can start by creating a bedtime ritual that allows your brain to disconnect from your code. It doesn’t have to be anything complicated just a way for you to relax and clear your mind. Maybe it’s taking a hot shower or stretching, the main point is making it a routine. Make sure you give yourself a good 15 minutes after you leave the computer to decompress and take your mind somewhere else. The key is to forget about the code, I promise you that the code will be the exact same in the morning as it was when you closed your computer. Once you have a routine in place it becomes easier for your brain to recognize it’s bedtime and therefore fall asleep.

Conclusion

Learning how to code can be a stressful time especially if you are fully committing your time to it. It is very important to make sure you are getting enough quality sleep. Coding nightmares can be a scary thing but with the proper techniques, they can be avoided. Find what works for you, stick to it and the coding dreams will be a thing of the past.

--

--

Billy Helm

Full Stack Software Engineer with a background in Petroleum Engineering