Programming is tough. Sometimes I need background music to keep things lively. But choosing songs is tricky. Anything with lyrics is distracting. Melodies that are new to me are jarring. Songs I've heard a thousand times only emphasize the dullness of a thick page of code. Sometimes silence is really the only solution, and I'm sure many programmers out there swear by it. But for me, if carefully selected, a little music goes a long way. Here are five of my favorites, matched to the coding dish with which they go best.

1. Architectural and algorithmic design

Philip Glass - Koyaanisqatsi Soundtrack

This is the soundtrack for a strange movie about the beauty of the modern cityscape and all the marvels of 20th century industry, like the New York City subway, nuclear power plants, space rockets, and explosions. Koyaanisqatsi means life out of balance, and the movie shows how, with industrious spirit and scientific discipline, humans are coming ever closer to bringing life back into balance, finally taming the barbarism of overgrown nature. Computers are the end game in our long struggle. And it's we, the programmers, who shall lead the people from desert and jungle, to salvation in the new reality, civilized and virtual.

The Koyaanisqatsi soundtrack is hymn to the technological revolution. It's both ode to our forebears in industry and hint of the transcendent abstraction to come. It stirs us at the event horizon of our humanity, that pivot point between this reality and the next. Save this music only for the grandest of programming problems.

2. Utility functions

Edvard Grieg - In the Hall of the Mountain King

Put it on loop. Type with the beat. Do da da da di da da di da da di da normalize a vector do da da da di da di da di da di da do a checksum on a file!

3. Parsing XML and the like

Clint Mansell - Lux Aeterna

XML is the programming equivalent of Jabba the Hutt. It's a bloated, sluggish thing whose company is deadly dull. I need a song that comes in like a Jedi Knight with a vendetta, and somehow makes parsing seem epic.

4. Memory management and threading

Silence

This is where the nastiest bugs are born. Sad to think how many security vulnerabilities have been caused by programmers rocking out to Rage Against the Machine. Best to keep things quiet.

...Then again, this is a post about music. So, if you can take it, I suggest:



Rob Dougan - Clubbed to Death

This one is weighty enough to convey the importance of thread/memory safety, melodic enough that you should be able to arrange most code calmly and correctly, and intense enough that the errors you do introduce will be epic and wild ones, which are worth having simply because they are too cool. Like this one.

5. Creative code

Ratatat - Seventeen Years

This is for when I really don't feel like working but I want to feel like I am working. I'm frustrated with all my scheduled problems, so I decide to be "creative." What I've been working on isn't going anywhere anyway. After all, I've already come up with a brilliant idea for this project: "create a great video game, with next-gen procedural effects and shaders, that will work on every computer ever, and will be fun because we will playtest it." All that remains is to implement it. I shouldn't be implementing things. Implementation is for mindless grunts, programmers. But I am software engineer, nay, architect, nay, artist.

I pull out a sketchbook, grab a shot of cappuccino, and scribble my UI-nouveau: each window is a planet, the desktop unfurls as celestial tapestry. On Google Docs now, new document: "Quantum Tunneling for UI Design." Biting burnt tongue reveals intriguing new pain. Paint my flow charts in pastel blue. Have to focus, back to code. But maybe, with quantum superposition...

In the end it's all a bunch of foos and bars. Atlantean relics rendered incomprehensible by the sober mind. When this humour hits me, I need music that's more indie than Thomas Jefferson racing a solar car in the Indy 500, artsier than Art Bell peeling arteries off a melting clock, and, yo dawg, trendier than trends that have trends. Okay, Ratatat's not quite this, but I like them, so there you go.

Do you guys listen to music while programming? Or perhaps while doing other work? Please share your picks!