The Soundtrack to Code
by Adam Tornhill, January 2014
To a programmer, noisy work environments are a devastating killer of job performance. Surprisingly, most workplaces still seem to ignore the problem and leave the root causes untreated. Instead the symptoms of a deep, severe problem are left to the individual programmers to address. A typical treatment involves earphones with music used to shield out the noise. This choice creates a personal auditory backdrop that may relieve the immediate stress but it comes at a potential cost. While music doesn't necessarily have a negative impact on our performance, it's important to understand how the degree and direction of the effect varies with the task.
The perils of noise
A quarter century ago, the seminal Peopleware made the case against dysfunctional office environments. In a comprehensive study on the correlation between noise levels and work performance, Peopleware reported that individuals in quiet working conditions were 1/3 more likely to deliver zero-defect work than their unfortunate peers in noisy environments. Even more interesting was that the correlation was stronger for increased levels of noise (DeMarco & Lister, 1999).
The results from Peopleware have been supported by multiple studies. They should be an alarming message to any company that depend upon the creativity, problem solving skills and quality of its employees. Translated to money, an 1/3 increase in zero-defect work should be a no-brainer investment. And that's even when just considering the immediate effects and leave the secondary consequences of a dysfunctional work environment aside. Probably, those secondary effects are even more severe involving long-term stress, health issues and motivation.
Despite these findings, companies continue to squeeze employees into crowded office spaces unsuitable for sustained concentration and novel creative work. And programming is definitely in that category. A failure to realize and adapt the environment to fit the demands of the tasks will have significant costs. Given the quarter century since Peopleware presented their findings I wouldn't hold my breath for an immediate change. There is no simple cure to the problem. In the meantime we need strategies to deal with averse working conditions. We need immediate workarounds and remedies. Music and, to an increasing extent, colored noise proves to be one such approach.
Music as a tool
To an individual in a noisy office environment, active earphones with a self-selected choice of audio is often the only practical and legal way to get rid of undesirable background noise. In situations like this music serves by minimizing external and unpredictable disturbances. The purpose of the music is as a tool that allows us to focus on the task at hand.
But music serves in a second role too. It's in this second role that we sometimes come to chose music as a coding soundtrack even under quiet conditions. The idea is that specific music helps us get into a state of flow. Flow is a state where we are completely absorbed in a specific activity. It's a state characterized by full focus and involvement. Flow is a well-researched state that's vital to the creative and complex work of software development.
Using music as a transition into flow is a double-edged sword. Personally, I often find that specific kinds of music serve as a bridge from previous activities, say a meeting or writing an e-mail, to the desired state of flow. Here music allows me to re-focus my attention. However, I do have to chose my music with care. Just as when we use music to shut-out disturbances, making the wrong choice runs the risk of either preventing increased focus or, even worse, pull me out of a productive flow.
To understand the different factors involved, join me on a brief journey through the research on music in the work environment.
The motivational dimensions
Before there were computers, in the era of blue collar workers, Wyatt and Langdon set out to investigate the effects of music on performance among industrial workers (Kirkpatrick, 1943). The workers in the Wyatt and Langdon's studies were engaged in simple and repetitive tasks. To them, work wasn't fulfilling nor did they have any expectancies on developing their own potential. Work was a way of paying the bills. A necessary evil.
In this context Wyatt and Langdon found that music did improve performance. There were additional benefits too. With music, the involved workers felt that the hours of repetitive work passed faster. Music helped them reduce the boredom of daily routine work.
Software development projects of today are often radically different. Many programmers enjoy their work. Some of us even invest our spare time in writing software, perhaps by contributing to the ever evolving open-source eco-system. To us it's not about passing time. Rather, the task itself fascinates us. We want to deliver our best possible work. Not just because we get paid but rather because programming itself holds value to us.
Ultimately it's about different sources of motivation. The most important and well-known psychological distinction is between extrinsic and intrinsic motivation. Extrinsic motivation is fueled by either an expected reward or a punishment for the performance or non-performance of a task. Basically it's old school management by carrots and sticks.
Extrinsic motivation was what got the workers in the Wyatt and Langdon to spend countless hours in the factory in pursuit of a paycheck. The other type of motivation, intrinsic motivation, is related to something we perform out of free will. It's something we do because we find the task itself interesting. To a passionate programmer, writing code for a new, exciting project often falls in this category. Consequently, the role of music in the Wyatt and Langdon studies doesn't apply. What would then the consequences be of adding music to our workplace? Let's find out by looking into some ideas about our consciousness and attention.
Two-channels, one consciousness
There's a disturbing fact about human consciousness. Despite our frequent attempts in the modern world we just cannot perform two conscious activities in parallel. Human attention doesn't scale; multiple conscious tasks will always compete against each other. And the more conscious involvement in a task, the higher the competition and interference.
If that were bad news regarding our conscious efforts, it may come as a delight that the majority of our cognitive processes are automatic. Automatic processes are unconscious brain activities characterized by their efficiency and effortlessness. Automatic processes are easily demonstrated using a sophisticated type of test known as two-channel experiments. This type of experiment also illustrates one of the perils with noisy work environments.
In a two-channel experiment, people receive two different streams of information. A typical research procedure is to read two different narratives simultaneously, one to each ear of the participant. Since we can only attend to once conscious stimuli at a time, the two streams just cannot be merged into a single conscious flow. When exposed to these conflicting sources of information, the brain selects one of the streams and masks out the other one. The observable behavior is that information passed to the mentally masked ear isn't encoded into the memory of the participant. As a direct consequence, the participant is unable to recall virtually any of that information. The competing narrative that was attended to is of course remembered well.
The fascinating part starts as we add information of personal meaning to the masked stream. A prime example on information of personal significance is our own name. As soon as that information of personal interest is presented our attention shifts instantly. Our attention now gets re-focused to the previously masked stream of information. The take-away idea is that while we may not be consciously aware of what's happening around us, our brain still scans and interprets the sensations in our environment.
That mechanism had a clear evolutionary advantaged; as our pre-historic relatives were daydreaming on their hunting trips, automatic processes kept them alive by drawing attention to that nasty sable toothed tiger that suddenly sneaked up on them. Today the same mechanism keeps its importance for survival (just think about crossing a street while absorbed in deep thoughts). They may also help us get through that cocktail party without missing out on mentions and gossips about our persona. Nonetheless the interruptions triggered by our automatic processes are concentration breakers. They're well capable of destroying our hard-worked focus in front of our favorite editor (Emacs). After all, these processes are about evolutionary survival so who wants to blame them for doing their work? It's not their fault the circumstances have changed drastically.
Today our modern, corporate world presents an environment radically different from the times when our brains evolved. Imagine yourself in an intense programming session in a room shared with friendly, yet chatty co-workers. Those precious automatic processes so vital to our functioning and survival now becomes a disadvantage and source of constant frustration. Similarly, surprising sounds and unexpected stimuli call on our attention. The slam of a coffee mug could well break a deep flow of any knowledge worker. No wonder that we often turn to music as an auditorial shield against the outer world.
The cognitive costs of music
Programming may well be the most cognitively challenging task we can undertake. Not only is the computer ruthless in its execution of our digital creations. We also need to satisfy the needs of a second audience: our fellow team members and maintenance programmers. Since that second group often proves to include our future self, we soon learn about its importance. As programmers, we thus have to switch between different levels of details and constantly balance competing dual goals. We have to constantly learn, re-evaluate and remember large amounts of details and idiosyncrasies about our languages and technical environments.
This chain of cognitively demanding processes is easy to disturb. The resulting consequences may be severe. Think about forgetting an edge case, or perhaps even failing to identify that there is one in the first place. It may boil down to competency issues, but there is often more to it. For experienced programmers ineffective encoding is a potential source of programming errors to come. The typical case is that we fail to remember a vital detail. Not because we somehow lost the memory traces but simply because we never attended to the information in the first place. In fact, failure to remember, the act of forgetting, is often rooted in ineffective encoding.
Conscious encoding is intimately tied to attention. If our attention is directed elsewhere or pending between competing stimulus we fail to commit information to memory. Both noisy environments and self-selected stimulus like listening to music are encoding distractors. Distractors that divide our attention. Without an effective encoding process we never get the information we need to reason about. Our understanding of the problem at hand is incomplete at best.
Now, picture that our encoding was successful. That brings us to our next cognitively sensitive mechanism. Our primary tool, the brain, has limited capacity for the processes programming relies on. One of those core processes involves the conceptual construct called working memory. Working memory is the mental workbench of our mind. It's what we use to hold information in our head and integrate it with existing knowledge. It's a cognitive component vital to high-level reasoning and mental manipulation of information. Our working memory is also a strictly limited resource.
Depending on the type of information, our working memory is able to hold a mere 4-7 items simultaneously. And that's under ideal conditions; when listening to music we drain this scarce resource further.
The research on the subject is quit consistent here; when it comes to cognitively challenging tasks, we perform at optimum in quiet conditions. If quiet conditions aren't possible, masking the background noise may increase performance but never to the optimal level reached under quiet conditions (see for example Loewen & Suedfeld, 1992 or Shih, Huang & Chiang, 2009).
Music or colored noise?
As a way around the cognitive costs of music, some programmers prefer colored noise. Colored noise is computer generated waves based on different mathematical models. The best known of these models is probably white noise, which is a random signal but with equal power in all frequency bands.
There's been a lot of interesting research into the field of colored noise. One frequently quoted study investigated white noise as a tool increase the attention in young students with attention hyperactivity disorder (ADHD). And indeed, white background noise helped the students in the study to reach performance improvements (Söderlund et. al., 2010). This sure is promising research. But the main problem when following up on the results is that they don't generalize to the population at large.Worse, the same research team found that white noise significantly hindered the attention of the students who normally paid attention.
Taken to our field of programming, these findings suggest that white noise works well as a noise cancellation technique but, just like music, it cannot compensate for quiet working conditions. Colored noise isn't a panacea either.
The subjective component
Ultimately, the choice between music and colored noise boils down to personal preferences. A recent study found that the influence of background music on concentration had more to do with the listener's fondness for the music than the particular type of music. It's an effect that applies to both ends of the subjective awesomeness spectrum of music preferences: the music that has the most negative impact on your concentration is the one that you either strongly like or dislike (Huang & Shih, 2011). The reasons are probably that the more a certain kind of music affects us emotionally, be it in a positive or negative way, the more of our cognitive resources are allocated to attend to it.
That research points us towards a local optimum. Within your musical preferences there's a likely to be music that's more or less suitable to code to. A further guiding principle is found in related neuropsychological research. That research suggests that our brain processes lyrical and melodic parts separately. For our conclusions, not only does music draw on or limited cognitive capacity; music with lyrics put an additional load on our resources. The lyrics seem to be a competitor for our attention.
Choosing our soundtrack
These conclusions leave us with a choice between instrumental music or colored noise. Both have the capability to reduce the distractions of random office noise and both imply a slight cognitive performance dip. Which one do we choose when we have to? Again, it comes down to personal preferences. Both alternatives will do. I'd give instrumental music the upper edge since it's associated with other positive side effects. One such effect is the common positive mood induction provided by listening to music. Music may also reduce mental stress and even inspire us on a long-term basis (Jiang & Sengupta, 2011). So, if it's going to affect your performance in a negative way, why not make the best out of it and make the cognitive distractor enjoyable?
Personally I prefer either instrumental music or music of ambient nature where the lyrics are less salient. Music, where the voice serves more like an additional instrument. My preferred choice is atmospheric black metal. It's a kind of music where the main goal is to put the listener in a certain emotional state. It's music of a highly meditative character that I found works well for both transitioning into the zone and maintaining my concentration once there. Similarly I've found that certain electronic music share similar qualities. Your mileage will probably vary.
All recommendations have to be put in a context. If you're searching for a distraction to get you through a repetitive routine task, music is an excellent choice. It may get you to perform slightly better and make the task more enjoyable in the process. Lyrics or not, choose your favorite acts here.
While music may well boost our mood and performance during routine tasks, it's negative toll on job performance during novel and cognitively demanding tasks is significant. The only thing that's worse with respect to auditory disturbances is a noisy work environment. Until that root problem is addressed, music remains a decent workaround with additional positive benefits on mood and motivation. You personal choice of soundtrack to code to will probably differ from mine. But for an optimal performance I do recommend selecting music with similar characteristics.
- DeMarco, T., & Lister, T. (1999). Peopleware: Productive Projects and Teams (Second Edition)
- Kirkpatrick, F. H. (1943). Music in industry.
- Huang, R., & Shih, Y. (2011). Effects of background music on concentration of workers.
- Jiang, X., & Sengupta, A. K. (2011). Effect of Music and Induced Mental Load in Word Processing Task.
- Loewen, ,L.J., & Suedfeld, P. (1992). Cognitive and arousal effects of masking office noise.
- Shih, Y., Huang, R., & Chiang, H. (2009). Correlation between work concentration level and background music.
- Söderlund, G., Sikström, S., Loftesnes, J. M., & Sonuga-Barke, E. J. (2010). The effects of background white noise on memory performance in inattentive school children.