Music and Programming: the loop

On the surface, music and programming couldn’t be more different. Music seems subjective and emotional, programming inhuman and cold. Beneath the surface, they have many similarities. The most fundamental is the idea of the loop.

In the parlance of our times, the word ‘loop’ literally refers to the electronic process of sampling, taking a small piece of one recording and playing it repeatedly, nested within another.

The verse/chorus/bridge pattern of any song is a form of branching loop. Musical notation has looping elements built in; indicators for playing a section again, or starting over from the beginning.

At the lowest level, sound is a loop. All sound is vibration, which is a form of oscillation: a change that departs from a point and comes back to it. At the highest level, an entire piece of music is itself a loop. You listen to it once, then go back to the beginning and listen again.

Programming can be described in the same terms of manipulating loops at different levels. The input and output of computer hardware is a loop: check for input, process data, send output, repeat. User interfaces are a loop between the human and machine — one acts, the other responds, they take turns. Entire programs are a loop in the same way as pieces of music.

Since all these similarities are based on the concept of loops, they are similar at a more fundamental level: they’re all about time. In the ancient classical view of knowledge, music was considered a form of science: the expression of number through time, analogous to geometry’s number through space. We don’t discuss programs’ functionality in terms of managing timing nearly enough, which is our loss. Even tasks like algorithms and data structures are largely about timing — presenting the proper data at the right moment.

Science has difficulty defining time. It’s a very squishy, human concept — imagine two people coming out of a concert, describing the same event as flying by and crawling slowly. Acknowledging the importance of timing in programming helps to bring the focus back to humans; and using the rigorous tools of programming in music helps create solid foundations built on numbers.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store