DEV Community

Cover image for Sleep More, Code More

Sleep More, Code More

Patrick God on December 19, 2017

Yes, you read that right. I know it sounds contradictory, but if you want to write more and better code, you have to sleep more. Let me explain. M...
Collapse
 
philsinsight profile image
Mr. Boateng

Great post! really great advice thanks!

I'm trying to improve my sleep, I use a Fitbit tracker to monitor my sleep and my average is currently 5 hours 👀. One thing that definitely helps is to leave all your distracting devices in another room.

I also often hear that 8 hours sleep is a goal that can be reached in one consecutive sleep cycle, or broken down and achieved throughout the day.

So if one were to sleep for 5 hours in the night, the idea would be make up for the lost sleep throughout the day, which may also be where the idea of power naps derive from.

would be good to hear your thoughts on this 👍🏽.

Collapse
 
petersimnz profile image
Peter Sim

Many lifetimes ago, before the Internet was ubiquitous, I was an aficionado of cryptic crosswords. Many evenings I would puzzle about particularly difficult clues. More times than not, the next morning the answer was glaringly obvious.

With coding there's often a tendency to keep going to solve the next problem and before you know it, the wee small hours are there.

I agree with the "Sleep More, Code More" premise. Even though you are asleep, your mind and brain keep working and when you're rested, you do look at seemingly insoluble problems with a fresh perspective.

Collapse
 
_patrickgod profile image
Patrick God

So true! I can't count the many times I struggled in the evenings and suddenly out of nowhere, the perfect solution came up the next morning.

Thanks for sharing. :)

Collapse
 
ponach profile image
rachid el kedmiri

The secret is to listen to your body, meaning if you need sleep then sleep.
Falling asleep quickly is overly underestimated, if done right you will save valuable minutes in which you are probably just staring at your room's ceiling. for me personally, once I lay down I don't don't do a thing -no phone, book, ...- and after a couple of weeks once lay down I pass out -my body is now programmed to rest I guess hehe-
My advice for those struggling with falling asleep quickly is to have patience and once in bed don't do a thing not even reading a book; sooner your body will be programmed to fall asleep within minutes (it takes me now less than 2 minutes to fall asleep).

Collapse
 
cantavest profile image
Rosanna Cantavella

Excellent advice, Patrick! We all need to sleep well. As to routines for going to bed:

(a) When? I'm a lark, not an owl. Once I confessed this to myself, my life became easier. My brain works much better in the early morning, so I go to bed at 9:30 pm, and am able and ready to work about 6:30.

(b) How? Yes, good advice: avoid screens in bed. Lighted screens, should I specify, as I read on my basic, ink-screen Kindle and have no problem at all. As to which genre, I try to avoid fiction, as I get hooked and can't stop reading! I've found essays, or even poetry (yes, poetry) much more conducent to sleep.

Collapse
 
_patrickgod profile image
Patrick God

Thanks for sharing your tips! It's true, a Kindle is a great exception. It works pretty well. I for myself often read kinda self-help books before going to bed (although it might not always be the best idea...). Maybe I should give poetry a try. :)

And regarding the time you're going to bed: Thank you! Sometimes it still feels awkward to be in bed and I see that 9 on the clock. But then again it's great to know that I can enjoy this lovely time knowing I will have a fresh mind early in the morning.

Collapse
 
dbell154 profile image
Dana Bell

I've discovered two things about myself. First thing is I've learned that power naps (5-15 minutes) can help make up for some loss sleep the night before and make me more alert.
Second thing is I've found a benefit in drinking coffee in the morning. One or two cups in the morning helps me get to sleep that night. It's like there is a crash after all the caffeine has been used up.

Collapse
 
prototowb profile image
Tobias Rauer • Edited

that sounds nice and simple 😌
power naps unfortunately don't work for me - I'm totally exhausted after waking up and need around 2h of real sleep, so the whole day usually is "%/&ed.
Coffee is also difficult, since it somehow makes me tired instead, when I drink it midday or more than 2 small cups (heard people with adhd have this problem, never got tested).

Collapse
 
rurban profile image
Reini Urban

And don't forget the mandatory afternoon siesta. After doing that my github contributions stats did skyrocket, ~2900/year.

Collapse
 
jillesvangurp profile image
Jilles van Gurp

No caffeinated beverages after lunch for me. I've learned the hard way that I sleep poorly if I don't stick to that rule. Which in turn means my productivity crashes the next few days because I'm too tired to function. I find actually closing my laptop and going home is often the fastest way to resolve seemingly unsolvable issues that just melt away the next morning; often in minutes. This has happened so often to me that I tend to just bet on this working instead of working late these days. In the same way, making the most of small breaks or weekends makes a difference when you come back to work.

Crunch time is a thing in our industry. But it has a cost. You are trading off short term productivity vs. mid term productivity. It's that simple. Crunch is inevitably followed by a crash. I'm not saying don't do it but be mindful that there's more to a project than surviving the next 48 hours by drinking too much coffee, not sleeping, and frantically trying to solve whatever problem needs solving. And BTW. your ability to do that completely tanks when you are tired.

I enjoy a good crunch once in a while but I compensate by mindfully slacking & procrastinating right after and taking time to get back to my normal routine.

Collapse
 
_patrickgod profile image
Patrick God

Thanks for sharing your thoughts on this. :)

I'm totally with you. If I have coffee after lunch, I still feel it in the evening. Currently, I even try to ditch the coffee and only drink green tea in the morning. Tastes great!

I also understand that you enjoy a good crunch. Sometimes, I also just love the grind. That feeling when you flow in the zone and don't want to stop. It's a great experience once in a while, but as you mentioned, it's crucial to also have a good portion of relaxation after.

Collapse
 
hkly profile image
hkly • Edited

I've been using F.lux, justgetflux.com, to filter out the blue light from my screen in the evenings so the screen light isn't as harsh as I code later in the day. You can customize the amount of filtering you want throughout the day and have the filter get stronger as the sun sets. There even is a feature that super filters your screen at 8 hours before your set "waking time" that serves as a reminder that I should probably get off my computer and go to sleep!

Collapse
 
darthmaul profile image
Darthmaul

Cannot say enough good things about f.lux! It's a great program and every dev should be using it or something like it!

Collapse
 
caffeinatedcake profile image
Cake

Very nice article, I enjoyed reading it. It also reminds me (again) that I should really make a real effort to tidy up my sleep schedule.

Since the subject seems to appeal to you, I'd like to recommend a book (if you didn't already read it, of course): "The Power of When", by Micheal Breus.

It was a pretty good reading that allowed me to start paying more attention to my bad habits regarding sleep, and has a lot of good advices on the subject. You might enjoy it too.

Collapse
 
_patrickgod profile image
Patrick God

Hey, Thank you very much. Also for your book recommendation. I will have a look at it. :)

Collapse
 
stephaneeybert profile image
Stephane Eybert

Drinking tea before bed time would prevent me from falling asleep as it contains cafeine.

Collapse
 
karfau profile image
Christian Bewernitz

Good hint. But that's only true for black/ green/ white tea, but not for tea made from herbs/ fruits/ rooibos/ ...

Collapse
 
wilsmart profile image
Wilmar Alberto Martinez Perozo

Thanks for the advice!

Collapse
 
_patrickgod profile image
Patrick God

You're welcome! :)

Collapse
 
nateous profile image
Nate

So I should stop reading this article an hour before bed... Great article!

Collapse
 
seyfer profile image
Oleg Abrazhaev

make yourself a cup of tea

bad advice. green or black tea still contains caffeine. so if I want one before the bed I have only fruit or grass tea.

Collapse
 
_patrickgod profile image
Patrick God

What about chamomile? ;)

Collapse
 
seyfer profile image
Oleg Abrazhaev

Yes, sure. Anything without caffeine suits for me. :)