How to Get Quality Sleep

This may be a weird article in a developer’s blog, but I think good quality sleep is fundamental when it comes to work that requires a lot of thinking and creativity.

I used to struggle with insomnia for quite a while. Besides that, I am a “night owl” — somebody who likes stay up late at night. I don’t think there is such thing as “night owls” and “early birds” though. I am convinced it’s a matter of habit, and modern life just calls for a “night owl” way. I know that because I have changed my sleeping habits numerous times in the course of my life. I also learned that insomnia can be fought successfully, too.

The first thing I discovered was that if you want to change your sleeping pattern, the most important thing to watch out for is the time when you get up. Not even wake up, but physically extract yourself from under your warm and cozy duvet. The time you went to bed isn’t as critical — in fact, if you stick to your desired getting up time, your body will adjust and regulate so that you’d be sleepy by the right time to get the right amount of sleep. Obviously, you would do well if you heed to your sleepiness :) Basically though, if you want to change your sleeping schedule, getting up time is the thing to change and track.

To help your body be sufficiently sleepy in the evening, you can use something like the Flux app, which will yellow your device’s screen at a certain time of night. Blue light that a typical screen emits tends to keep us awaken and alert. Besides, the app yellows your screen gradually, and at the peak time the screen becomes so dim and yellow that the device is barely usable. That would be your Q :) Often at night I would turn my computer off altogether and just read a book under a yellow lamp before going to bed. I found that to be the least disruptive for my sleep.

Physical activity is crucial as well; however, there is a danger of having too much of it, especially if you’re into weight training. Too much of physical or mental tiredness disrupt sleep for me. Everybody is different, and there is no certain answer as to how much exercise a week or how many hours of programming a day will induce insomnia for you. I actually kept a sleep journal for a while, where I tracked things like hours of mental work (including my hobbies and programming on the side), physical activity, eating habits, amount of coffee I had, stress etc. — everything that could affect my sleep.

On the same note as keeping a journal I can highly recommend meditation. I heard some research says it can have positive effects on sleep, but for me its primary benefit lies in its ability to teach you taking a note of yourself — how you feel, what happens to you, what affects you and so on. In other words, meditation teaches you to be present with your life (which we aren’t 90% of the time).

My last advice would be to resist as much as possible various aids like sleeping pills or ear plugs — those might make things even worse. Wearing ear plugs for a nearly a year aggravated my sensitivity and made my sleep really fragile. When ear plugs were not available, the tiniest noise would wake me up. Worried, I stopped using ear plugs altogether. After initial sleepless period, my body tuned its noise sensitivity down a bit, and everything was back to normal!