How Sleep Affects Your Code🤔
The stereotype of the hardcore programmer (c/o Elon Musk) is one that can code for 20-hour stretches. Fuelled only by caffeine and ramen, this mythological creature is up to 100x better than an average coder who spends their time on trivialities like family and fun.
I hope you know that this is a damaging lie. Even the best of us needs a good rest to be able to perform when we are in front of the keyboard. Here are the main factors getting in the way of your sleepy time, and what to do about them.
Sleep Deprivation != Hardcode Coding
Software engineering is frequently compared to elite sports, and in sports sleep hygiene influences predisposition to injury (evidence).
If you’re worrying about deadlines and difficult to solve problems you might wake in a cold sweat, and your sleep disrupted. This quickly results in impaired cognitive function (evidence).
If you aren’t getting 8 hours of sleep a day your performance will suffer. After 16 hours awake your cognitive performance drops off, something you simply want to avoid as a software engineer
Software engineers should get 7–8 hours of sleep as adults and give themselves the best chance of creating great code (evidence), as they’ll be more mentally engaged and ready to perform.
This stuff matters. So, we need to find what is impacting the sleep of software developers, and what we can do about it.
Causes of Poor Sleep
Caffeine
You might rely on caffeine to keep up your performance. This is likely if you do not have sufficient time to sleep, and this makes sense since caffeine improves logical reasoning during periods of restricted sleep (evidence).
However, caffeine too late during a working day may inhibit sleep (and therefore produce further dependency on caffeine) (evidence) and produce a negative cycle while feeling culturally appropriate (evidence).
As a software engineer cutting caffeine should go hand in hand with getting enough sleep.
Stress
Software engineering these days works on a premise of constant deadlines and pressure (thank you, Agile). A taxing work environment can also negatively impact sleep hygiene (evidence), in turn making developers feel even more stressed. Stress is also negatively correlated with productivity (evidence).
Hardcore work cultures encourage long hours with benefits like free meals (which are beneficial to the company, not the employee), coupled with a death-march pace to complete projects producing stress and anxiety.
Software engineers should choose a workplace that helps to handle stress in their workers and ideally provides an environment that is low-stress for employees.
Poor Rhythm
You have a natural rhythm and cycles of productivity and rest that go against the ideas we are fed about being a coder who can work for 20 hours straight and remain productive.
In fact, we can focus for 90 minutes or so, and balance this with rest to produce the highest performance from ourselves. Your mind passes through an alternation of focused and multitasking modes (evidence), and software engineers should harness these patterns of focus.
Software engineers should understand that your day is full of peaks and troughs, and harness this to make sure that your performance (coding time) fits into where your body is best prepared to perform.
Blue Light
Software engineers use machines that typically pump out blue light from their LEDs. This can cause sleep disturbance and negatively impact software developer’s productivity (evidence).
Controlling one’s environment is important and provides a way to make our work life better. Software engineers should consider using blue light glasses and stopping work at a time that enables them to get a full night’s sleep.
Conclusion
If you feel that you’re tired you need to understand this does have an impact on you and your work.
You owe it to your employer. You owe it to yourself. You might even live longer.