I just read an interesting article at BusinessInsider.com entitled Why Programmers Work at Night.

The article explains why programmers generally tend to prefer working in the wee hours of the morning.

Programming requires keeping a lot stuffed in your brain at once, and thinking about all of it all at once. This task can often be a tad difficult under normal work/life circumstances.

In short:

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.

If you have ever programmed anything, you understand the above 3 paragraphs perfectly.

Still, there is a better way…

Now, you know the drill.

Most people think that coding something isn’t that bad. After all, it’s just like changing an alternator in a car, right? I mean, you have to change one part of the car, and then you’re done.

Of course, the “rest of us” know that it’s not quite that simple. It’s more like:

You have to change the alternator in your car. You start to change it, but of course changing the alternator means that the A/C doesn’t work any more, and that depends on whether or not there are rubber duckies in the trunk. If there are, then if the seats are upholstered in leather, you have to check the angle of the steering wheel. But if the seats are cloth, then the only thing that matters (unless you’re worried about security) is if the rear windows are more than halfway down.

BUT, it gets worse, because even though you’ve straightened everything out, and your new alternator is installed and functioning without breaking or modifying the functionality of the rest of the car, the car itself can no longer go faster than 50 mph. It’s those damn rubber duckies in the trunk!

So, back to the drawing board, only this time you also have to keep in mind the brand and size of the tires, their level of inflation, the color of the paint, how recently that paint was waxed, and whether or not the brake pads were recently replaced. Oh, and don’t forget the type of fuel being used, if the fuel filter is clean, how much oil is in the engine, and if there is a spare tire or not.

In other words, you never change just one thing when programming – you must keep the entire model in your head so that you can “see” how everything works and affects everything else. This requires a certain amount of a particular kind of brain power, very few distractions, focus, and it doesn’t hurt to actually be a bit creative after all those other requirements have been met.

Also, as the BusinessInsider article mentioned above, we work at night because our bodies are tired, our brains have had a full day of fuel, and all the other “doing busy work” parts of our minds are exhausted, leaving the “let’s get down to business” parts active and focused.

There is also the fact that when all the other parts of our mental machinery are winding down, the creative juices can more readily find expression. Suddenly, we have a “bright idea” that is no longer drowned out by other concerns and annoying thoughts about this or that. This “bright idea” thing is an important clue.

Want to come up with a bright idea for some coding problem? Take a shower or bath while lightly pondering the problem – as in, think about the problem in a very general sense without trying to actually solve it. Repeat to yourself the parameters of your problem, and then let your mind wander as you bathe. This is guaranteed to give you a bright idea, or two or three. The water is also important – trust me.

And that brings me to my point: You don’t HAVE to program at night.

Let’s face it, most of us don’t have jobs (or lives!) that will let us do this, and it isn’t healthy anyway. Screwing up your sleep patterns is a sure way to screw up your health. So, what to do?

I recently programmed a custom WYSIWYG editor for Sott.net. I don’t mean the kind of editor you find in WordPress like the one I’m using right now – that’s FWYSIWYG. The “F” stands for “Fake” since the “Visual” view doesn’t actually show you what your content will actually look like when you view it as a normal article on the web site.

No, I wanted to make a real, honest to god, contentEditable-done-right RWYSIWYG editor (the “R” stands for “Real”), where what you see when editing is EXACTLY what you see when you view the article itself when published.

So, I started thinking about it.

I would prepare by reading some things for a couple of hours each night at a reasonable hour – say, sometime between 6pm and 11pm. Then I would let it “simmer” as I described above with the bathing trick. Are there libraries I can use? Has anybody done this before? Did it work the way I want mine to work? Am I crazy?

Eventually, I started coding it. There were, of course, many problems and trials and tribulations. The way I dealt with these problems was new and innovative – at least for me! When I hit a wall, I didn’t code until 4am like I used to do. Sometimes, when we think we’re “pushing hard” until 4am, we’re just spinning our wheels. It’s not like you’re guaranteed to get a lot done if you work at night…

Instead, I would let it simmer.

Sometimes, I would let it simmer for days. I didn’t have a deadline, I didn’t know if it would work in the end, and most importantly, I didn’t care. It was an exercise in doing something cool, and in a cool new way.

Invariably, the solution would hit me, usually while showering, and suddenly I’d be at my computer at 10pm. I would code the solution within an hour or two, and then go to bed. Bam, problem solved. The next day, I would carry on doing the things I had to do that were most definitely NOT programming, and let the next problem simmer.

I coded almost the entire RWYSIWYG editor in this way, and I am quite proud of the results for 2 main reasons:

  1. It was something I had wanted to do for ages, but didn’t think I could
  2. I didn’t kill myself staying up until 4am coding as I had in the past – I worked smarter, not harder (or later).

The bottom line is that the human mind works in mysterious ways. Coders also work in mysterious ways. But programmers are all about solving problems, and when to code is one of the biggest problems of all.

Since I couldn’t change my day, and I didn’t want to compromise my health, I reckoned that I would simply “recode” how I coded in the first place.

So, yeah… This is what we’re faced with, and the circumstances outlined at BusinessInsider are what generally happens when it comes to programmers… But that doesn’t mean you have to just go with it. The truth is that coders are (necessarily) kind of OCD. This is a good thing, but it must be managed, just like your time.

Use your brain’s natural background cycles to crunch on some problems for you. If you’ve read about various human cognitive processes and related studies, you know that your mind is exceptionally good at interpreting and processing data – and dealing with problems – WAY faster than you can do it consciously… See Malcolm Gladwell’s Blink: The Power of Thinking Without Thinking for starters.

Let it simmer, stop obsessing so much, and see what happens. I think you will be surprised at the results.

Need help? Hire me!
Get Scottie Stuff!