Early on in my career, when I was a software engineer, I was debugging some horrendous problem that was crashing the system. I remember reading through the problematic code, thinking “What kind of idiot writes crappy code like this?” , until I scrolled up to the top of the file, and what-do-you-know, that idiot was me. I couldn’t believe it! I couldn’t even remember when I wrote that piece of code! So I looked up the source history of the file, and sure enough, there it was: “Submitted by Aditya, 3:05 AM 3 weeks ago”Over the next couple of days, I found over a dozen bugs in the same file. That one late-night of coding 3 weeks ago had cost me over 3 days in trying to fix the problem. This horrible waste of time was painful, but I decided to do some research to find out more. From the source control system, I pulled up all submits I had made to fix bugs. Then, for all the fixed bugs, I found out when the buggy code had originally been submitted. The results were shocking: 60% of the bug fixes were made on code that was originally submitted after 9 pm.
Was I really such a klutz? Was I really becoming so ineffective after 9 pm? I repeated the same research, but for everyone else on my team. Sure enough, an average of 65% of bug fixes were made on code that was originally submitted after 9 pm.
This is not hard to understand. Software is the pure distillation of human thought. And when you are tired, stressed, sleepy or in any way not at your 100%, you as a programmer become useless. It’s actually worse than useless – tired programmers introduce horrible bugs that are difficult to track down and take up 3x more time to fix. So net-net, working 6 hours extra today will waste 18 hours of time 3 weeks from now. The corollary is also true: If you don’t work when you’re tired, you can cut down the bugs in your code by 2/3rds! Instant productivity gain!
This is a two-sided coin, though. If you want to be productive during the day, you really have to focus during the day. Research has repeatedly shown that humans are horrible at multi-tasking, and distractions are enormously harmful to concentration. Studies have shown that even a small, 30-second distraction (like checking facebook/twitter) can take 30 minutes to recover from! Another study found that for a knowledge worker’s productivity, distractions are worse than getting stoned. Researchers have also shown that multi-tasking can actually cause your IQ to fall up to 10 points! Summary: Distractions and Multi-tasking are very bad for you!
Since this revelation hit me, I’ve been a big advocate of making sure that programmers don’t write code when they are tired or sleepy. When I discuss this concept with other folks, the usual defense is that “Working hard is required. Especially in startups!”. But when we get to measuring programmer productivity, the results are usually clear: The most productive programmers are the ones that come in at a reasonable hour, leave office at a reasonable hour, and are 100% focused on work during the day. No facebook, twitter or other distractions. There’s plenty of time for that after 6 pm!
This also has a profound impact on your startup's culture. If your employees, especially the younger ones, see that they are being rewarded and patted on the back for "staying all night" and "working really hard through the weekend", they might mistake it to mean that it is their effort that is rewarded, rather than the actual thing that they got done. This is a slippery slope - soon, people feel like they have to stay back "because everyone does it" and you will slowly see the quality of work sliding without explanation. Unfortunately this is the hangover of the "study-last-minute-late-at-night" culture from college that carries over to the workplace. While you can get away with mugging last minute in college - which doesn't need much cognitive attention -, it does not work in real life where cognitive attention to your work is of paramount importance.
This is definitely a controversial opinion, but I’m not alone in advocating this. Sheryl Sandberg, the COO of Facebook (and earlier a VP of sales at Google) openly admits that she leaves office at 5:30 pm. Patrick Pichette, Google’s CFO, once wrote in a company-wide email that he leaves for home by 6pm and then doesn’t check his email when he’s at home! If the COO of a startup with 800 million users and the man that manages billions of dollars of revenue can leave for home at 6pm, why can’t you?