[This essay has been expanded into a book, you should read it, here]

A chimpanzee brain at the Science Museum London

Image via Wikipedia

A popular saying goes that Programmers are machines that turn caffeine into code.

And sure enough, ask a random programmer when they do their best work and there’s a high chance they will admit to a lot of late nights. Some earlier, some later. A popular trend is to get up at 4am and get some work done before the day’s craziness begins. Others like going to bed at 4am.

At the gist of all this is avoiding distractions. But you could just lock the door, what’s so special about the night?

I think it boils down to three things: the maker’s schedule, the sleepy brain and bright computer screens.

The maker’s schedule

Paul Graham wrote about the maker’s schedule in 2009 – basically that there are two types of schedules in this world (primarily?). The traditional manager’s schedule where your day is cut up into hours and a ten minute distraction costs you, at most, an hour’s worth of time.

Prim clockwork of a wristwatch, watchmaking ex...

Image via Wikipedia

On the other hand you have something PG calls the maker’s schedule – a schedule for those of us who produce stuff. Working on large abstract systems involves fitting the whole thing into your mind – somebody once likened this to constructing a house out of expensive crystal glassand as soon as someone distracts you, it all comes barreling down and shatters into a thousand pieces.

This is why programmers are so annoyed when you distract them.

Because of this huge mental investment, we simply can’t start working until we can expect a couple of hours without being distracted. It’s just not worth constructing the whole model in your head and then having it torn down half an hour later.

In fact, talking to a lot of founders you’ll find out they feel like they simply can’t get any work done during the day. The constant barrage of interruptions, important stuff ™ to tend to and emails to answer simply don’t allow it. So they get most of their “work work” done during the night when everyone else is sleeping.

The sleepy brain

But even programmers should be sleeping at night. We are not some race of super humans. Even programmers feel more alert during the day.

Ballmer's peak

Ballmer’s peak, by XKCD and shame on you if you don’t recognise the style

Why then do we perform our most mentally complex work work when the brain wants to sleep and we do simpler tasks when our brain is at its sharpest and brightest?

Because being tired makes us better coders.

Similar to the ballmer peak, being tired can make us focus better simply because when your brain is tired it has to focus! There isn’t enough left-over brainpower to afford losing concentration.

I seem to get the least work done right after drinking too much tea or having a poorly timed energy drink. Makes me hyperactive and one second I’m checking twitter, the next I’m looking at hacker news and I just seem to be buzzing all over the place..

You’d think I’d work better – so much energy, so much infinite overclocked brainpower. But instead I keep tripping over myself because I can’t focus for more than two seconds at a time.

Conversely, when I’m slightly tired, I just plomp my arse down and code. With a slightly tired brain I can code for hours and hours without even thinking about checking twitter or facebook. It’s like the internet stops existing.

I feel like this holds true for most programmers out there. We have too much brainpower for ~80% of the tasks we work on – face it, writing that one juicy algorithm, requires ten times as much code to produce an environment in which it can run. Even if you’re doing the most advanced machine learning (or something) imaginable, a lot of the work is simply cleaning up the data and presenting results in a lovely manner.

And when your brain isn’t working at full capacity it looks for something to do. Being tired makes you dumb enough that the task at hand is enough.

Bright computer screens

This one is pretty simple. Keep staring at a bright source of light in the evening and your sleep cyclegets delayed. You forget to be tired until 3am. Then you wake up at 11am and when the evening rolls around you simply aren’t tired because hey, you’ve only been up since 11am!

A city

Image via Wikipedia

Given enough iterations this can essentially drag you into a different timezone. What’s more interesting is that it doesn’t seem to keep rolling, once you get into that equilibrium of going to bed between 3am and 4am you tend to stay there.

Or maybe that’s just the alarm clocks doing their thing because society tells us we’re dirty dirty slobs if we have breakfast at 2pm.

Fin

To conclude, programmers work at night because it doesn’t impose a time limit on when you have to stop working, which gives you a more relaxed approach, your brain doesn’t keep looking for distractions and a bright screen keeps you awake.

You should sign up by email to receive tips and science about productivity and keeping your sanity as a developer, here.

Enhanced by Zemanta

You should follow me on twitter, here.

Get 10 of my best articles and talks

Leave your email and over the next few weeks I will send you the best material I've written since 2010.

  • dev

    For me it’s also the pressure in the evening, that the whole day didn’t happen much… so in the evening the day is soon finished, and there have to be some results for being a good day!

  • Avihu Turzion

    I think Cliff from cheers put the basic phenomena best in this quote: http://blog.pilnick.com/post/66268775/well-you-see-norm-its-like-this-a-herd-of

  • http://twitter.com/epic_n00b Anil

    Good read :)

  • Rich

    I’ve noticed that when I’m very tired I’m better at playing computer games that requires fast action. My brain seems to go into some kind of auto pilot mode where it just reacts instinctively instead of thinking to much of what it’s doing.

  • http://tomaszsobczak.com Tomasz Sobczak

    Just briliant!

  • Stefy1995

    YES! you are so right!

  • http://twitter.com/Sarab_SQLGeek Sarabpreet Singh

    Gud one dude, but even DBAs work in Night shift and hold many of them true for us also. 😉

  • http://www.facebook.com/profile.php?id=9701252 Paul Clay

    This literally describes me from the last 6 months.  I was living in a different personal time zone.

  • Wickedproxy

    I am not a “coder”, but I am writing a sifi book. I do the same thing. I think about the the story as a whole and how I want it to go. Then I start to fill in the gaps and add detail to the story. An interruption brings this to a screeching halt that I usually don’t recover from that night. Doing this is nearly impossible for me during the day.  

  • http://www.icu-india.com http://www.icu-india.com

    very nice and a amazing post on programmers schedules enjoy reading this post a lot 

  • Brunnengert

    That’s true for me also! I enjoy working at night, especially when I have short time limits. The only thing is … you can’t get a “normal” functioning life when you continue like this. I’m not talking about a day job or family, you can sure keep up with these. I’m talking about the Morning. It’s beautiful at the Morning, you have the hole day in front to do a lot of other things besides coding. Conclusion: Try to balance working night & day, it’s hard but it pays off!! Cheers!

  • Pingback: Почему программистам лучше работается по ночам? — Бложег Анисимова()

  • Donlukehart

    Agree with keeping whole set of code in brain at one time. Hated it when clients would come up and say, “I know you got that whole thing in your head, but….” Then they’d bitch because it took so lone.

    :Less distractions at night. NO meetings. LOL

  • Pingback: A geek with a hat Why programmers work at night | «Rod's space()

  • Alex

    Not bad, but you missed the big one: historically, computing time was not cheap, and often the only free time available was at night.  It’s only in the last 30 years or so that the idea of a “personal computer” really became feasible.

  • http://twitter.com/dotjinks Brian Rowdy Hamby

    AGREED! Simple if the world around you is quieter at night. Mental resources wasted in the day trying to be disciplined and maintain focus when the rest of the world around you is awake can be applied to the code at hand instead of wasted battling distractions.

  • Anonymous

    “Somebody once likened this to constructing a house out of expensive crystal glass and as soon as someone distracts you, it all comes barreling down and shatters into a thousand pieces.This is why programmers are so annoyed when you distract them.” I’ve heard this a million times and it seems so self-congratulatory. Every professional specialty has a variant of this, essentially “what I do is the most important stuff in the world, my time is worth more than your time, etc.” As a developer who gets interrupted all day long, I am nevertheless able to get my work done in a reasonable amount of time. I don’t bitch and whine about interruptions by my stakeholders, because that is part of my job.

  • http://swizec.com Swizec

    The point isn’t that you complete or don’t complete your work on time, the point is how much do you like to be interrupted?

    Instead of considering it a part of your job to be distracted, how about finding an approach that works for everyone 😉 Schedule time when you are available for interruption, then have a slot of time when you produce stuff.

  • Pingback: 12/20/2011, News « Software as Art()

  • http://saicyberspace.blogspot.com Sai Sayson

    I’m not a programmer but I feel you man! I also work this way. I feel so productive at night and I’m with you regarding your “no distraction” reason :)

  • f1rstman

    Did no one notice that that’s a chimpanzee brain in the glass jar?  Is this some subtle commentary about programmers in general?  :^)

    Anyways, I generally find it very difficult to work at night unless I am really excited about what I’m doing.  If it’s something I HAVE to do, being up alone late with no one around and endless distractions (e.g., Reddit) makes for an unproductive work environment.  I might try getting up early though.

  • http://www.agustinpolito.com/ AP

    It’s better work without distractions, without noisy telephones and context switching. This are, IMHO, the main causes that make programmers go to bed at 4 am.

  • Pingback: 21 декабря 2011 «()

  • Pingback: A geek with a hat » 5 months of blog traffic in 4 days()

  • Roberto Gambuzzi

    To be “in the zone” is quite similar to be in trans. Shamanic-programming!!!!

  • Sumitrk2002

    I think programer want to work on diffrent-different time Sometime at late night and sometime at early morning. it will create intrest

  • http://twitter.com/nmosafi Neil Mosafi

    Try pair programming, problem solved

  • Pingback: Linuxette.org » Pourquoi on croit mieux coder la nuit()

  • http://twitter.com/Tech_Thread Brett Martin

    Ah yes, the lovely glow of the computer screen invigorates me to keep pumping out the code.  That is for sure!

  • Pingback: 为什么程序员喜欢在深夜工作 - 博客 - 伯乐在线()

  • http://twitter.com/Shaken_Earth Thomas

    Since it seems to me that the author seems to be right in what he says, how do companies expect us to work during the day?

  • Dennis Mnuskin

    Love the article and personally relate to it 100%.  In “Bright Computer Screens” you weren’t sure if we stabilize at 3-4am because of alarm clock or social pressures. Don’t know about others, but for me it is only alarm clock.  Last thanksgiving break, having few days off, I ended up shifting all the way to noon of the following day :)

    This article may not have described me when I programmed in high school or college or even first few years on the job, but for more experienced developers this is definitely the case.  And it has nothing to do with just pointy-haired boss, there are other team members, QA, tech support people, e-mails, other random interruptions.  I find that most of the time I don’t even try to write code at work anymore.  If anything, I just leave early and start coding when my wife goes to sleep.

  • Pingback: 【外刊IT评论网】为什么程序员都是夜猫子 | 何振科博客()

  • Pingback: Pourquoi les développeurs travaillent-ils la nuit ? « Parce qu’être fatigués nous fait mieux coder » « la révolution pacifique blog libre()

  • Bill

    l think early morning is reasonable, cheating sleep is hard, you can find yourself awaking with your face on pads!! but for those wanted to attend offices/classes and need to concentrate to customers all day, l think they must have other way to make their things done!!

  • Sawyerrken

    You are not cheating sleep, you are shifting your timezone in your head. When others are sleeping you are working, when others are working, you are sleeping (or not, that’s your choice).

  • Eric

    Great artical.  This is pretty much the reason I work at night.  Avoiding the irritation of “I could get it done if you stop calling me”.   Know one is calling me at 2am.  It’s when I get the most done.  

  • http://twitter.com/odenaxos olivier dahan

    With your paper a lot of us are now stopping to feel all alone… Being all so differents but having this stabilization phenomena at 3 / 4 am is really astonishing.
    The bright screen reason seems to be very relevant.
    Concentration is also the mean reason, there is no place in a normal day to have 3 or 4 hours of work without any interruption. Night is perfect, it lets you “loading the context” without losing it.
    But this has a price, with age coming, your biological clock is working worse and worse and it becomes harder and harder to resynch with the “normal” world… (not speaking about the plumber that comes at 8 o’clock in the morning and you can’t miss him because he will not come again before 6 months… !).

  • Pingback: 为什么程序员都是夜猫子 | Flash开发者大会()

  • Bris_g

    I like this article. I’ve programmed for work and a hobby, and my brother has programmed for a major games company for 10-15 years. When I worked as a solo software developer for two years, I did all the health and fitness things during the day and worked during the night 6hrs for 6 days a week. I did really well, probably the best ever in my life, until I had to change back to day work. My brother worked at the office during the day from 10am to 6pm, would come home for dinner, go out, then come home and work from 10pm to 4am. We have a lot of distractions at home and we use the quietest times to get our work done. We also rely on music to block outside distractions. For two years now, I’ve used the state library in the evening after my day job to work on web projects. This is where I agree with Dad’s comment from 2 weeks ago, playing familiar music can help focus. This isn’t my golden dream, working day and night – I’d prefer my routine from when I was a solo software developer, but this is my reality for now. I agree with the bright screens but I work in the evening 3pm to 8pm and use a black background when I code. After all, I get up at 4am for my day job. Good article :-)

  • Pingback: Konsentrasi di Malam Hari « Zaki Akhmad()

  • Jérémy Cochoy

    I write code for fun, and actually, I’m more efficient the night, between 11pm and 3am. You’re right when you say that during the day, we can’t stop looking mails, news, etc. Even if I’m in a quiet place, alone, I’ts really hard to make me do the job until the night, although it’s so easy to be caught by the pleasure of code writing after 11pm!
    But I’m thinking that, maybe, being a little bit tired could be the source of imagination and creativity.

  • Pingback: Why programmers work at night… – Odyssey Of Mayhem()

  • Alan

    Sounds a lot like ADD.

  • Pingback: Working at Night | Andrew Cross()

  • Pingback: 为什么程序员都是夜猫子 | 老邱()

  • Pingback: Les geeks sont des nocturnes - FomoBlog | FomoBlog()

  • Pingback: A geek with a hat » Blogging, hats, stuff()

  • http://www.facebook.com/profile.php?id=1645485530 Sascha Lührs

    Want to increase your IQ by 10-30 points? Use brainworkshop.net for 20 minutes/day and join its corresponding google group.

  • MoonLightning

    I just had fun reading the article

  • Jkirk3279

    When everybody else is sleeping my mind expands, as if having other conscious minds buzzing around takes up vital cycles I need for concentration.    

    I have thought that perhaps the Sun’s radiation and radio noise might have something to do with it.

  • Eila

    I totally relate to what you said here. There is “I-didn’t-do-shit” thinking too, but it’s not exclusive. Many thanks for making me feel better because society in fact does make me feel like a “dirty dirty slob.” Pfff… the world is ruled by greedy early-riser despots whose money doen’t make them sleep till 11am :)