The Quest for Programming Zen

23 02 2011

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

Ever since the beginning of video games, cold hard numbers have reported progress and skill in video games. It’s nearly impossible to find a video game that doesn’t contain scores, levels, or character experience counters. Programming can also provide some empirical measures of progress in the form of line numbers, file sizes, code check ins, bug counts, and requirements met. As you’re programming you have a mental road map of where you’re going, and you have some idea of how close you are. The future may be filled with unpredicted obstacles impeding your progress toward your goal, but video games are similarly unpredictable. Sometimes level 20 seems right around the corner, but you get stuck trying to defeat a group of enemies or conquer a troublesome city. The constant desire to further your progress drives you forward.

2. Multiple long and short-term aims

Video games don’t just reward the player at the completion of the game, but incrementally guide and reward them on their journey. Similarly, programming is not just about getting to the completed program. The program consists of many objects, functions, and small individual pieces that must be constructed before we get to the final integration. Each of these smaller tasks is a short term goal, a specific thing to keep your mind focused and busy on, all the while making progress toward a long term goal.

3. Rewards for efforts

Rewarding effort is a mysterious thing. On one hand, you might not think that watching crops grow and getting money for them to plant more crops would be rewarding, but the millions of people playing Farmville prove otherwise. The reward for video games usually comes in the form of unlocked weapons, levels, and character perks. In programming, the reward is the satisfaction of creating a program and having it run correctly. Programmers simply enjoy what they do, and in a zen like way, are rewarded just by doing it and doing it well. There are, of course, also financial and academic rewards associated with many programming projects.

Computer Problems (XKCD 722)

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.

7. People

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.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: