Every good programmer knows what it’s like to have a programming spree. For some it’s a rare but wonderful occurrence, for others it’s a daily thing. It’s those times where you stay up until 3:00am trying to perfect a piece of code, then wake up in the morning still thinking about it. It’s those times where you code for 8 hours straight at work and get yelled at by HR for skipping your lunch break. It’s those times you become so immersed in your work that your mind doesn’t wander, get tired, or get bored. It’s an illusive and spontaneous thing, impossible to force yourself into if the conditions aren’t just right.
What causes such sprees? What separates mind numbing tedium from intense programming that you love to do? And are we as software engineers alone in this feeling of zen? We’re certainly not alone, but it may be surprising that the near cousin in our quest for coffee induced super human attention spans is not another engineering discipline, but rather a form of entertainment: video games.
I was watching a video lecture the other day on 7 ways that video games reward your brain. The single most interesting thing I find about video games is their ability to engage people’s minds for long periods of time. Instead of vegetating in front of a TV, they make people actively solve problems, compete against other people, and make seemingly tedious things nearly addictive (see Farmville), but without feelings of boredom or burnout. Does programming reward our brains the same way that video games do?
1. Experience bars measuring progress
2. Multiple long and short-term aims
3. Rewards for efforts
4. Rapid, frequent, clear feedback
This is something that separates software engineers from other types of engineers, and is quite possibly a reason why someone like electrical engineers don’t obtain the same zen like states that we do. An electrical engineer will take design requirements and spend the majority of their time painstakingly creating schematics for the design before they even get close to having a real device to look at and test. Software engineers on the other hand, will compile and test pieces of their code literally hundreds of times a day. Of all the engineering disciplines, software engineering is the one with the most rapid and frequent feedback.
5. An element of uncertainty
If you were playing a video game where every enemy you killed dropped the exact same items, or enemies always appeared in the same size groups and locations, the game would be far less fun. Do elements of uncertainty make programming more interesting? Your first thought is probably that you hate uncertainty when programming, and anytime something uncertain happens it’s usually some sort of frustrating bug. However, there is an element of uncertainty in program design that could equate to this in video games. If you designed a program in your head, every little detail, and then began to program it, it would be a very boring procedure of typing away at your keyboard inserting the appropriate code into the computer until done. However, that’s not even a possibility in programming. Instead, a high level view of the program is constructed in your mind, and like an artist creating a painting, the visual feedback he receives from every stroke of the brush effects the next. You don’t sit down knowing what your program will look like, but rather you build the program up from your mind in an uncertain fashion. The element of uncertainty in programming is actually a byproduct of our brains inability to predict and fashion the entire program in our head. The limited scope of our brains means we can’t see what we’re going to create in even the near future.
6. Windows of enhanced attention
A game consisting of nonstop action is tiring. They do exist, and can frankly be a lot of fun (see the open source shooter Nexiuz), but the design of the game must be different to counter the mental exhaustion. Death matches between players have to be quicker, and competition has to fuel the attention span that would otherwise wilt. A more common theme is using windows of enhanced attention. The actual size of these windows is a science and art that video game designers have been striving to perfect since the beginning of games. Finding a balance between exhausting amounts of action and giving the player too much down time to relax and let his attention wander is not a trivial challenge at all. Does programming contain windows of enhanced attention? Definitely. The size and length of these windows vary depending on the type of programming your doing, but the actual programming is the enhanced attention window, and the debugging/testing is the downtime.
Single player video games can be fun, but ultimately have very short lifespans. The games that live on for decades (World of Warcraft) are games that have a good interaction with other people, providing both competition and teamwork. Likewise, individual programming projects can be fun and hone one’s programming skills, but in the end it’s the large scale projects that will live on. Starting an Open Source project is analogous to starting a game clan. You have a goal, and you find other people to join you and help complete that goal. You also have large scale competition among companies and projects (Firefox vs Chrome, Google vs Bing).
Perhaps in looking to our video gaming cousins in computing, we learn a bit about our own psychology. Is this what the zen like programming zone is? Working and competing with others on a constant drive forward, measured by metrics of progress, and filled with uncertain challenges with both long and short term goals as we’re rewarded and given rapid feedback.