Tag Archives: programming

Sleep and my attempts at hacking it

A few quick notes from a whole bunch of sleep related books I’ve been reading, and some of my sleep/wake experiments I’ve been running on my own. It may be relevant for most people but more so for programmers like me.

You don’t need 8 hrs of continuous sleep, most current research seems to suggest that for every 2 hrs of wake you need 1 hour of sleep. Sleepiness increases as the wakeful hours build up. This means that catching naps is quite effective in being alert. One of the biggest thing to look out for is a full sleep cycle, in which you pass from light sleep to deep sleep and then REM sleep. REM sleep is the last stage of each cycle and possibly the most important (studies have shown that ability to learn goes drops dramatically when deprived of REM sleep).  It is also the easiest to awake at the end of the sleep cycle (depth of sleep gets lower as you approach REM sleep), typically this period is about 90 minutes to 110 minutes long. You feel freshest waking up at the edge of your sleep cycles, and disoriented when woken in the middle of deep sleep. The trick is to sleep in a quite room and wake up naturally (as against using alarm).

Color of light during the day and evening before sleep is very important, lots of us use Flux which changes the color of your computer monitor to brownish/reddish during the evening. It helps because blue light from monitors/iPads/TV’s/fluorescent lamps etc. delay the onset of sleep. It’s important not only important to change the monitor color but also switch over to incandescent bulb during the evening for the same reason. On the other hand wakefulness in the day is enhanced by bright of light, so having bright (blue light or natural light) is great to maintain alertness during the day.

Most humans have a period of day called the ‘wake maintenance zone’, this is the time around dusk when despite sleep build up we resist sleep, supposedly this was the period in the day when humans were under highest threat from animals during our stint on the savannah. We’ve evolved to be more watchful and alert around this period. This about a couple of hours around 6-8 PM . I’ve personally found this period to be the most productive (via RescueTime stats). This is also the time we fritter away either drinking in pubs or stuck in traffic instead of hacking productively at work.

Figuring out your chronotype is extremely important and plan your day around it, instead of around set schedules of  work at 9AM and home at 6PM. This is because your body clock controls when you are alert/hungry/sleepy rather than the time of the day. But it is really hard to manage different social times with internal time, this is where entrainment comes into play. Light is a really powerful zeitgeber for entrainment. For later chronotypes like me (most programmers?) it is useful to get enough sunlight in the day, so that it’s easier to sleep early. A quick heuristic: 2 hrs of sunlight in the day pulls back your normal sleep time by about 1 hr. Couple hours of cycling to work seems to do the business for me.

Temperature of the body plays a important role in sleep and we sleep faster (or better?). Body temperature drops as we sleep and a drop in temperature induces sleep. So it is harder to sleep after a vigorous run or walk, or a hot shower, because both increase your body temperature. I’ve personally found cold water shower to induce sleep. Also during the REM stage of sleep your body loses its ability to regulate body temperature (along with most muscles) and will follow the ambient temperature and hence it is important to sleep in a place which is not too cold or warm.


Internal Time : An excellent book on Chronotypes by a sleep researcher.

Dreamland:  On sleep/dreams etc. good fast read.

Flux Sleep research Page

Entrainment of human clock

Sleep wake rythms and cognition

Wake Maintenance

A course on sleep

Caring for Craft

Apologies for the Rant.

A few years ago in between jobs I spent 3 months hanging out in Madgaon, Goa. Sounds like a lot of fun, and it was. But when money used to run out,  We’d have to go find work and for me and some of my friends it meant going to Madgaon Docks and work on daily wages as Longshoreman. Basically that meant Moving loading unloading stuff,  fixing minor mechanical issues, operating cranes et al. It was intense physical work in the hot sweaty Goan sun. It was not fun but it had to be done to support my lifestyle. For a day of hard work I’d get paid almost the same amount i get paid what I’d get in an hour’s work as Computer Programmer, actually lesser.  Being a Longshoreman is easy, everybody in decent physical shape can do it, and there is no talent required here.

It was easy to recognize, that some people cared about doing it right read piling stuff up correctly, and not taking extended tea and lunch breaks) and some people did not.

That was the time I realized despite the tough conditions, people want to care about what they do. That’s when I started to realize appreciating what you do, and not do it just for the money, which is what I’d been doing.

At my current job I  regularly meet a ton of run of the mill programmers ,  just doing enough to get the job done, without a thought about craft. It’s not really hard to program badly, anybody who can Google, and Stackoverflow can easily write something that works.  But you really need to care about your craft to make it work well, and not pile stuff on top of other stuff and just get it done, especially when we are getting paid so much for what we do.

When i mean care for the craft, I have very little idea of what it means but i have a few heuristic questions

  1. Is it exactly what the customer was looking for?
  2. Am I making the right technology choices knowing what I know about the Project?
  3. Have I made it Better than it already was(Faster to run, easier to read, specific to the need)
  4. There is no 4th Question.

If Knowledge is Silver, Outlook is Gold, and IQ is just lead weight”. -Alan Kay