34 comments

[ 2.9 ms ] story [ 84.2 ms ] thread
I do not like programming at night, but sometimes it is difficult to stop.
"I think it boils down to three things: the maker’s schedule, the sleepy brain and bright computer screens."

I think a lot of it boils down to being expected to perform in really noisy not-conducive-to-thinking environments (yes, open-plan office, I'm talking about you)

At least, that's been my experience over the last 30 years.

Less distractions at night, so hard to get a few hours of uninterrupted coding time in the day to really dig into something.
Parhaps offtopic, but f.lux ( https://justgetflux.com/ ) adjusts the screen brightness when it's getting night/late...

It's awesome for programmers :)

I don't like how it doesn't change the screen brightness. So I hacked together my own tool that uses DDC to control the brightness and color of the screen. However ... the nvidia driver (in Linux) crashes when you use DDC to much. The alternative seems to be pulling the DDC wires out of a DVI cable and using a alternative DDC controller ...
Gtk-redshift has gamma and is ime way more stable than flux on Linux
Whilst I don't disagree with the points in the article, I think the primary reason for the increase in productivity at night is the 'soft' deadline - knowing that I really should go to sleep, but perhaps I can just finish off One Last Thing. I find the same effect from working in a cafe (I've been here a while, I really should free up this table), or even just from drinking lots of water and needing to go to the bathroom.
This is entirely consistent with my experience since I was a teenager.
My thoughts exactly. "I should really stop now, but i can make an exception for this one last thing, while i am so good at it. [workworkwork] Done. Oh, and then there is this other one last thing [workworkwork]..." is the most powerful kind of flow, because the illusion of the current task being the last one helps focus like few other things.
>Because being tired makes us better coders.

This is a far-fetched claim. The argument doesn't hold water and it is less convincing given that the author only uses his own anecdotal example of how he is forced to concentrate given low energy to back up the claim. Willpower needs energy and thus most people need energy to concentrate on difficult tasks.

I like to work at night for his other reason that there is almost zero distraction save the social media feeds. However, I think my well-being in the day time is being compromised as I do so. Haven't found a good solution to that yet.

While his claim is anecdotal, the idea is not. There are psych and drug studies that suggest the same. Also, my own anecdotal evidence says that both working late and the Balmer Peak are effective for just this reason.
Now im just an amateur programmer so a bucket of salt here, but i prefer early morning before my wife and everyone gwts up on the weekend is the most productive for me.
Professional programmer here, totally agree with that, I'm not more productive than between 7am and 12am.
"Because being tired makes us better coders."

I've never noticed that being tired makes me code better.

It might also depend on the kind of code you're writing: there could be a difference between how fatigue affects our ability to write straightforward code vs. algorithmically complex code.

But I agree that programming late at night (or at least after everyone else in the office has gone home) makes me more productive because it limits distractions.

This is anecdotal, unscientific and has no real basis to it what so ever, but I have one possible interpretation.

I'm overly critical of everything if write, be it code or prose.

I tend to overcomplicate things when I write. I think too far ahead and tend to get paralyzed of by the matrix of things I thing I need to consider. I think I need to understand the problem in its totality before I can write anything.

As I get tired, I get less critical, and possibly my short term memory gets worse. Suddenly I'm in a situation where instead of constantly being critical of my ideas, I have to keep of writing them down just to remember them and to fully formulate them. The part of my brain that tells me it's crap has fallen asleep. And the part that kept taps of EVERYTHING has shrunken down to only hold a few items or ideas at a time.

And suddenly the code is there. Done. I wrote it. Now let's write the next idea before I forget it. I'll go through it all later.

The effect is most obvious for me with prose. I used to get nothing done during the day. I just kept thinking all my writing is worthless. But then at aroun 1-3 AM, I would write a dozen pages. I would barely be awake, but my fingers would fly almost like on auto-pilot.

This is SPAM!

The original blog post, written by Swizec[0] can be read on his blog: http://swizec.com/blog/why-programmers-work-at-night/swizec/...

Can mods please change this submission?

[0]https://news.ycombinator.com/user?id=Swizec

Oops, sorry. It did confuse me why a good article was on an otherwise spammy site, but I didn't reach the obvious conclusion. Thanks for pointing it out, and to 'dang' for switching.
My view is that we work at nights / early morning because it's quiet. If I could manage to work in a quiet environment during the day, I would.
Yes, even at home, during the day you are interrupted by:

* Phones ringing and other such interruptions

* Lawnmowers or leafblowers

* Seemingly incessant construction with drills, saws, hammering

When the sun goes down, these distractions go away and you can concentrate.

I disagree that /all/ programmers can be more productive at 2am rather than 10am.

Indeed, day-to-day Real Life[tm] stuff really does get in the way, and I myself have raged due to the frustration of having my concentration broken by e.g. my wife coming in asking some mundane question outwith the context of the problem I'm working on - it is literally a mental disaster when that happens.

I'm of the opinion that it's more likely that bugs are introduced in your code due to your cognitive functions being affected by sleep deprivation, which potentially offsets time gained via coding at night.

So whilst you /do/ have the time to build that model in your mind during the wee hours, I reckon it's more likely for there to be either en error in your mental model, or errors creep in during the translation from mind to machine.

I don't know what the answer is - choosing to be a coder makes for a very difficult situation, especially if you happen to be one of those coders who also have a wife - even more so if you've fork()ed a child process or two!

I've no doubt that there will be some quite exceptional humans out there who can manage to have a family life, work in a busy place with lots of interruptions, or can code till 4am and are /still/ able to work super-productively - but for the rest of us mere mortals, sleep deprivation == degraded cognitive function, and/or trying to code through normal hours == constant frustrating interruption.

Now, where's my coffee? ...

I completely agree. I used to have a fairly strange sleep schedule that moved gradually till I was finally waking up at 2 PM. I'd then spend one night/day without sleep to reset it. While I got plenty of uninterrupted time it wasn't very quality time. These days, I work remotely from Europe while the folks I work with, work in PST. That means most of my mornings/afternoons provide uninterrupted work time. I find that I get a lot more done and I can handle all my meetings post 5:00 PM.
I am usually up by 4am in the summer and 5 or 6am in the winter. This is my favorite time to code. I used to be a night owl but have found I produce worse code when tired. Interestingly weed seems to help me stay on track during the day.
As a part-time freelancer who also has a full-time job, I often don't have a choice but to code late at night or early morning.

I honestly hate working at night, simply because I often miss small things that cause silent bugs. On the other hand, coding at early morning (5-6 am, before my wife and kid are up) feels really great.

OT, but would you mind sharing how you got your moonlighting gig? I'm looking for something myself, but don't want to participate in the race to the bottom on the usual freelance sites.
Because nobody's going to talk to you or you're not supposed to be somewhere else doing something else.
This is entirely anecdotal. I'm very very skeptic that "the most productive time" is very late at night (or waking up at 4am). Yes, there's some work done in the evenings (6pm-8pm) or at 6-8am, but that's more an indication of a noisy workplace or with multiple interruptions.

And getting into some sort of "pushing the limits to focus" sounds very daft. Specially if done often, the quality of the work will be very bad.

There are people that like to work by night, that's for sure. But I think that's the minority compared with the ones that like to work at reasonable hours (including the ones that start later than the standard 9-5)

> And getting into some sort of "pushing the limits to focus" sounds very daft. Specially if done often, the quality of the work will be very bad.

I find I'm more productive at certain types of tasks (including programming related ones) when I have a certain level of fatigue. My brain can be noisy even if the workplace isn't, and fatigue reduces that noise.

Even for my own anecdote, however, this absolutely does not generalize to all types of tasks, and absolutely does not mean "pushing the limits", and I'll certainly agree it can be a daft excuse for a daft mistake that will result in some really daftly written code.

> I find I'm more productive at certain types of tasks (including programming related ones) when I have a certain level of fatigue.

For me, reaching that fatigue means going to the gym. I feel like the physical fatigue helps me to get into a form of mental focus and tranquility. Even though I usually hit the gym at 8PM and return circa two hours later, I can keep pushing code for at least three more hours.

I also play competitive video-games with my friends, who keep on saying that they play better during the nights. Most of them are not into sports, but they can still say to be mentally more focused.

Whilst I cannot really prove that I would produce better code during the nights, the matchmaking in the games do turn out to have a trend of win streaks. I succeeded to rank myself to the fourth topmost ELO pool by playing during mere midnights. To reach that rank from the previous one, it requires approximately 12 wins in a row, which is not an easy feat.

About the original post, I also reason staying up late because the time difference between US and my current residency is such that any Github issues, PR's or emails tend to be sent at about midnight my local time. By staying awake an hour or two more, I can deal with those tasks to wake up to a less busy day.

I developed the habit of working at night due to time sharing on slow computers. I could timeshare a VAX 11/750 or 11/780 with 60 of my closest friends during the day, or with three of them at night, when everybody else had gone home.
I also have the theory that being tired, helps you in that you can't distract yourself. The brain is too tired to jump around.

My q is: Is this ADHD?

(comment deleted)