Music and Coding

Music and Coding

I love coding.  I love music and coding. My ideal day in the office is one with a long to-do list and a clear calendar.

One of my favorite ways to block out background noise is to put on a set of headphones and fire up iTunes, Spotify, Pandora, or Grooveshark.

I”ve long wondered why the two activities fit so well together. The music I”m listening to can impact my energy level, level of focus, productivity , and sometimes even my passion for the project I”m working for. Perhaps, music is just a great way to cancel out background noise, allowing increased focus. Or, maybe music stimulates the same logic or mathematics-oriented areas of the brain that coding does. Skills like pattern-recognition, inference, and abstraction are common both to both. I”m no psychologist, but my own empirical observation has shown a heavy overlap between the programmers I know and friends who count seeing or making live music as a hobby. Maybe it”s self-selecting, but I think there may be a shared set of innate qualities between the two populations.

Or, perhaps as an engineer I am simply doomed to attempt to vigorously try to reverse-engineer everything I come into contact with. Though the practical merits of listening to music while I code are clear to me, I”d never realized how similar the process of writing a computer program is to writing a piece of music: Galghamon, a stackoverflow.com commenter who studied both music theory and composition, notes:

Musical notation is a lot like a system spec: There are varying amounts of information present, from which you have to make educated guesses about what was intended. Composing music on paper is a lot like writing a system specification. The more you spell out what you want (using all the notational elements available), the more faithful to your ideas the final performance of the piece will be. But just as you can have coders that ignore some of the specs, you”ll have some musicians that will improve on the piece by ignoring certain instructions and providing their own interpretation. Sometimes this works, sometimes it doesn”t.
Writing code is a lot like playing music: you interpret the instructions of others, internalize them, interpret them, until you can deliver a performance. There”s no clear right or wrong with either, just degrees of faithfulness to the original thought or intent, but there”s a goal in both (even improvisations follow a certain style and direction). How well that performance was executed is left for others to judge (audience, users), except when your playing or programming for your own pleasure.
Debugging and testing is a lot like hearing your a composition played for the first time – there are often wrong pitches in the notation, simple notational errors, but sometimes you can tell that something just isn”t working right in an ensemble, so you have analyze the problem and look at why this is. You can do trial runs with users/audiences to see what their reaction is.
[ Click through to read the whole thread ]

So there you have it. Some musical pieces can be engineered or reverse engineered, the same as how us hackers can engineer a website, program, or video game.

But anyway, I”ve digressed. 🙂

After a chat with a close friend about music and code, I”ve come up with three themes I consistently see in good coding music:

  1. Fast Paced.
  2. Instrumental, without lyrics.
  3. Heavy on melody and rhythm

Genres like classical, jambands, and electronica fit right within these themes. But, basically, I’ve found that anything instrumental (without the spoken word, which I found interferes with my ability to code) works.

Some of my favorite artists for coding:

  • Classical:
  • Bach,
  • Mozart
  • Beethoven
  • Jamband:
  • Lotus
  • Explosions in the Sky
  • STS9
  • Cut Copy
  • Radiohead

Do you see any parallels between music and code? What are they? What do you listen to to help you focus?

Comments are closed.