Why developers like to code at night

A nocturnal work schedule is the key to creativity and productivity for many open source programmers.
164 readers like this.
Why and how to handle exceptions in Python Flask

Image from Unsplash.com, Creative Commons Zero 

If you ask most developers when they prefer to work, many will say their most productive hours are at night. This may be especially true for open source contributors who are contributing to projects outside of their day job (though hopefully within healthy limits to avoid burnout).

Some like to start in the evening and work till the early hours while others get up super early—say, 4 a.m.—to get most of the programming work done before the daily grind kicks in.

This work habit may make many developers seem like oddballs and misfits. However, there are quite a few reasons why so many programmers prefer to work during the odd hours:

The maker's schedule

According to Paul Graham, people who "produce stuff" tend to adhere to the maker's schedule—they prefer to use time in units of a half-day or longer. In fact, most developers have the same preference.

For one thing, developers work on large abstract systems and need the mental space to process a model in its entirety. Having their schedules sliced into 15- or 30-minute chunks for emails, meetings, phone calls, and interruptions from co-workers is simply counterproductive.

For another, it's often not possible to program effectively in units of an hour; that's barely enough time to wrap your head around the task at hand and get started.

Programming is also adversely affected by context-switching. By working at night, developers can avoid as many distractions as possible. Without the constant barrage of interruptions, they can spend a few solid hours focusing on the task at hand and be as productive as possible.

The peaceful quiet

With the background noise of various activities (e.g., office chatter, traffic on the street) mostly absent at night or in the early hours, many programmers experience a sense of relaxation. This allows them to be more creative and productive—especially when tackling mentally stimulating tasks such as coding.

The solitude and peacefulness, plus knowing that they'll have a few uninterrupted hours, often take the stress and time pressure associated with a daytime work schedule off their shoulders, allowing them to produce higher quality work.

Not to mention, there's nothing like indulging in your favorite midnight snacks when you have solved a thorny problem!


Developers working on open source projects can have a different communication cadence than a programmer working in-house at a company. Most open source communication is done asynchronously through channels like mailing lists or GitHub comments. A lot of times, other programmers are in different countries and time zones, so communicating in real-time often requires developers to be night owls.

The sleepy brain

This may sound counterintuitive, but as the day wears on, the brain gets tired enough so it can only focus on a single task. This essentially eliminates multitasking, which is a major hurdle to staying focused and productive. But with a sleepy brain, you can't afford not to stay focused!

Also, many developers often make the most significant progress when they go to sleep thinking about the problem they're trying to solve. The subconscious mind goes to work, and the answers often come to them in the early hours when they're still half asleep.

This is not surprising since sleep boosts brain functions, helping us make sense of new information and think more creatively. When the solutions present themselves in the wee hours, these developers just get up and hit the ground running without missing a beat.

Flexible and creative thinking

Many programmers experience an upswing in creativity at night. The prefrontal cortex, the part of the brain associated with the ability to concentrate, gets tired at the end of the day. This seems to clear the way for more flexible and creative thinking for some people.

According to Brant Hasler, assistant professor of psychiatry at the University of Pittsburgh School of Medicine, "with less of that top-down control and 'cognitive inhibition,' the brain might be freed up for more divergent thinking, allowing one to make new associations between different concepts more easily." Combined with the positive mood made possible by a more relaxed environment, developers can come up with innovative ideas more easily.

Also, without distractions and having the space to concentrate for several hours, you can "get in the zone." This helps you better focus on a project and get in the flow without worrying about things happening around you.

Bright computer screens

The sleep cycle of many programmers is delayed because they look at bright screens all day. The blue light from computer screens disrupts our circadian rhythm by delaying the release of sleep-inducing melatonin, increasing alertness, and resetting the body's internal clock to a later schedule. As a result, developers tend to go to bed later and later.

Influence from the past

In the past, most developers worked at night out of necessity because shared servers didn't have the computing power to support programming work while everyone else in the company is using the servers during the day. Developers needed to wait until late at night to perform tasks that weren't feasible during the day, such as testing projects, running extensive code-compile-run-debug cycles, and deploying new codes. Even though servers are more powerful now and most can support the demand, the trend to work at night continues as part of the culture.

Final thoughts

While there are many reasons why developers prefer to work at night, keep in mind that being a night owl doesn't mean you should skimp on sleep. Lack of sleep leads to stress and anxiety and, ultimately, burnout.

Getting enough quality sleep is the key to maintaining good physical health and brain functions. For example, it helps you integrate new information, cement memories, think creatively, remove accumulated toxins, regulate your appetite, and prevent premature aging.

No matter what your schedule is, make sure to give your brain the rest it needs so you can be on your game and as productive as possible—all day, every day!

What to read next
Matt Shealy - ChamberofCommerce.com President
Matt Shealy is the President of ChamberofCommerce.com. Chamber specializes in helping small businesses grow their business on the web while facilitating the connectivity between local businesses and more than 7,000 Chambers of Commerce worldwide. Matt is a seasoned marketer and technologist working with technology powerhouses like SAP and Campaign Monitor.


I am not a coder, but I think its peace that every programmer is looking for, and they find it easy doing programming at night. What say?

As a freelance developer since 2012...I always prefer working in the night time

It seems to me that what is happening is not so much that coders "prefer" to work at night as much as the fact that they drift into it because it works. It works because it's efficient -- one gets more productive work done when you can concentrate on what you're doing, and not be distracted or interrupted by other people, or even the disruption that regular meals makes in the day.

Sadly, at this point in my career, I'm doing far more business-type activities and far less coding, but I can still tell you that there is nothing more painful than being "in the zone" writing code and then being interrupted by a phone call or a coworker asking a question.

I also think that the night-owl attitude starts in college. You go to your classes by day. You hang out with your friends in the afternoon and evening. And then you need to work on your projects - which means at night, because that's the only time you have left.

I, and too many programmers I know, never went to post-secondary for that to be true. I really believe it's simply the extra space to think. Personally I have a hard time working in a broom closet.

In reply to by David C.

When I get a chance to dive into a project, I might spend a long day working up to shortly before I go to sleep, if inspiration hits I really have to pull myself away because I have spent 24 hours at a stretch working. If I hit a block before I go to bed I will quite often have a plan of attack by the time I wake up, even if my solve doesn't pan out. Even if I'm excited to work, I know at this age to just keep myself in bed for 6-7hours or else I regret it and my work suffers.

A good nap will bring a fix or two now and then; especially when you feel cornered. I get solutions that way often.

Thank you for this article. This makes so much sense to me that even when I am really tired that I can still get a couple of hours development work at night after I my kids go to sleep.

Nah, as a developer I only use the night for sleep. I too much love sleeping to skip it during the best time for it :)

Solitude + Peacefulness + Uninterrupted = In The Zone.

Very well written article.

Try noise cancelling headphones. They Do wonders while working in the morning
If you go against your natural sleep patterns you will pay for it later (I've been there)

yes.. in theory.
in practice, it's because of f**ng deadlines!

and of course the classic 'death march' model of software development when writing software late into the night is needed to ensure a deadline is met.

I can only speak for myself with over 30 years of programming experience. So many managers, CEOs and colleges have tried to get me into an office between "working-hours" and it just failed - EPIC. In an office I get distracted all the time and when I finally have "the flow" some security is chasing me out of the building due to closing time.

Being a programmer isn't like flipping burgers or any other job where you perform predefined tasks and then go home. Programming is a creative and highly abstract process. Reading well written code is like reading poetry and for any artist, let it be a painter, author, designer etc. we can't be 100% creative and productive between 08:00 and 17:00. We all need different environments to thrive and stimulate our mind. When I get stuck I simply need to distract myself by spending time with friends, go down town for some coffee, watching people and just relax. I know that my subconscious will keep processing the task at hand and suddenly a solution will pop-up in my mind from nowhere. However this can be a bit tricky in the middle of the night if you are in a sleepy small town.

So when all my colleagues, CEOs and managers gave up on me and let me roam freely I got rid of all watches and alarm clocks. I go to bed when I'm tired, sleep as long I want and then get up to work (for example I went up 15:20 today). This might be in the middle of the day or night, it doesn't matter, I listen to my own body instead. This puts me on my highest performance and I do prefer the night over the days.

I love this article. It explains why I prefer to be up at night and sleep during the day. It is so-o-o much quieter at night so I can concentrate and get a lot more done. Unfortunately, the "get a lot more done" only refers to what I can do on a computer. Anything else would wake up my family members.

I no longer code much, but I do blog and do quite a bit of personal research on the Internet.

For me, it works! Coding at night is the best choice, because there is quiet place, and cool weather.

as for me writing and coding at the night is the best way for creating new idea,at the night site there have no more disturbance

Can't speak for others but for me, it's to avoid distractions.

Thank you for this article Matt! It's nice to know I'm not the only one who finds it easier to focus at night - usually writing though rather than coding :) Interesting to read about the "why" behind it, and glad to see you caution against losing out on too much sleep!

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.