Why developers like to code at night
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.
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!