post-title Sikilabs - Music and the performance of coding | Blog
sikilabs.com music_and_coding

Music and the performance of coding

How similar are making music and programming?

Posted by ibrahim on Jan. 30, 2020

People who work in science and technology often share the same unfortunate stereotype: geeky people who are most likely to be found in solitude at a lab or at a desk in some dark corner late into the night. While the geeky part holds some weight, the second part that paints us as asocial, single-minded people is pretty far from reality. The fact is, rather than spending our nights in dark corners, a lot of us are more likely to be found on a dark stage, moonlighting as musicians. Brian May, the guitarist from Queen? He’s got a PhD in astrophysics. And vocalist Mira Aroyo from Ladytron? A PhD in genetics. The list goes on and on.

Why do so many of us science and tech types also play music? This is a question I often ponder here at Sikilabs, particularly when I take a break from coding to play a few riffs and imagine myself jamming with the likes of Ali Farka Touré and Enrico Macias.

When I work, listening to music helps me focus throughout the day. But when I pick up my guitar, even just for a minute, music becomes something different, something relaxing. Beyond the obvious diversion of doing a different activity, it draws upon my nature as a programmer to make something with a clear result. But rather than satisfying someone else’s pre-defined requirements, my end-goal is just to make the music I play sound good. It’s an alternate way of using my creativity, focus and logic.

At first glance, music and and coding seem to be completely opposite fields, but the similarities actually abound. In programming, you start with a few lines of code and get them to work together. The same is true with playing music. You start with a few notes and build on them, making sure they sound good to the ear, like something people would want to listen to. It requires some basic knowledge and skill, in the same way that we can’t just put any old lines of codes together and expect it to work.

What is a song, anyway? If you think about it, a song follows a very identifiable logic. For example, a modern pop song usually starts with a verse, moving to the refrain, then a new verse, then the refrain, then another verse. Perhaps on the second refrain, a slight variation will be thrown in to speak to the listener’s emotions, and then the song comes to an end.

It wouldn’t be so hard, then, to transpose a song into code. Essentially, it would look like one big loop. The code would include conditional statements to perform each distinct verse, and another conditional statement for the variation of the final refrain. Indeed, I’m not the only one to think so — the people behind the open-source Sonic Pi app see coding as a way to make music, and music as a way to teach kids and adults alike to code. In addition to helping people understand coding through something they’re already familiar with, the app can also be used for “live coding”, where code is tweaked on the fly and the result heard instantly.

At the end of the day, there is something intangible about music that cannot be automated. The soul of music, the freedom of expression. For programmers, music is a way to use logic to build something great that we can share with others and see the results instantaneously. For us, music is simply the performance of coding.