Music & Coding: Similarities and Differences

November 12, 2021

For me, a website is like a complex symphony score, with many details organized in a structured manner. Could be a complex detail-oriented one (like Enescu’s, Mahler’s, Bruckner’s), or simpler like Haydn’s or Mozart’s. For many years, I was trained as a professional musician, I played and taught piano, I read complex scores, and wrote articles, and made books about music. In the last 5+ years, I replaced music scores with websites, music notes with code. Here is an article where I wanted to connect both worlds and both languages from my personal experience.

Coding is more similar to music composing and less with playing an instrument, as I see in many online discussions. Playing an instrument is reading and performing a score. In programming, this is similar to reading and typing code and it’s just one step in the learning process.

Just as coding means developing structures and patterns and using them in an organized structure to find solutions, a musical composition means a collection of musical patterns and structures in an organized form aimed to send a message to the audience.

The learning process implies many activities for learning music and learning code. There are similarities and different approaches as I have found in the learning & practice journey:

  • Both music and programming are complex languages that must first be understood and then practiced.
  • First, we need to learn the basic vocabulary and theory. As a musician, music theory was my favorite class and I understood concepts very easily without connecting to real-life music. As a coding learner, theoretical concepts are useless without real-life examples.
  • Practice starts with small challenges/projects for coding – with small pieces generated by a few notes, for music. The level of difficulty is gradually increased.
  • Reading the code of others like reading others’ scores is an important activity in the learning process.
  • Both music and programming involve working with micro and macro elements: musical motifs, themes, parts of a whole system vs coding syntax as for, while, sections, short snippets etc.
  • Performance means working on bigger projects as well composing masterpieces (sonatas, concertos).
  • Both require many hours of practice without seeing the results.
  • While learning music is almost always supported by a teacher (mentor), learning programming is usually a solitary activity.
  • Teaching others is the most effective way to learn code, and it is a recommended practice, even at the beginning (writing content about the learning journey). It may be possible with music composition, but it’s not as effective a method as working with a mentor.
  • Learning music requires you to play 3-10 pieces in a year, repeating thousands of times; learning programming requires you to tackle many new projects and difficulties in a short period of time.
  • While learning an instrument (as a professional) takes 10+ years for a single instrument, programming puts pressure on you to learn quickly and adapt to many languages and frequent changes.
  • Playing music is a kinesthetic activity, while programming requires less movement, which has less of an impact on memory in the long run.
  • Learning music encourages analytical thinking, especially through reading scores and analysis. Coding is about more abstract thinking, using concepts, and linking those concepts to objects.
  • When you play a composition (usually from memory), you do not think about the theory behind it, you just feel the music and send a mood to the audience.
  • Musical composition implies an original piece of music or (less commonly) an original idea of combining the musical ideas of others as quotations.
  • Programming (short) courses are like musical masterclasses. They add some value through the experience of others, but they are no substitute for self-study and are only a small part of the overall learning process.

Does learning music has benefits when learning to code?

Practicing for hours helped me develop a strong commitment to working for hours without being disturbed (A fun fact is that I was taught to play the piano without hearing the audience, even when the lights were off or something was happening nearby!) Reading and analyzing many complex scores trained my mind to develop a structured mind and easily discover patterns and similarities in a complex system. When I work on a complex front-end project, I approach it like a symphonic score. Another great benefit is that memorizing long (30-40 minute) musical compositions has helped me think ahead, structure by structure, part of a whole idea.

I do not know if it’s because of the music training, but I have found over the year that abstract thinking is not my strong suit. Visual thinking along with analytical thinking helps me work more comfortably.

More on this topic: 1, 2, 3, 4