Similarities Between Music and Programming


I started programming and learning music around the same time. I never thought about any kind of relationship between the two until many years down the road. As of now I have been doing both for over twenty years and I have noticed many similarities. These are my personal opinions as both a student and a teacher of programming and music, although I do cite several scientific studies on some topics.


The first similarity I noticed is with people's perception and misconceptions. There is an aura of mystery for many people that persuades them it is too difficult or complex for them. They feel like they just don't "have it" or weren't "born with it". Some believe you need a talent granted by a special gene combination or a special type of brain. This mentality discourages many people from trying.

Another perception I see often is the idea that music is predominately creative and programming is predominately technical. I feel they are almost the opposite. When I play music, even improvisational blues and jazz, I am thinking very technically about the chord progression, key signature, chord tones, timings, rhythms, dynamics, effect pedals, volume knobs, tone knobs, pickup switches, what the other musicians are playing, any head nods or eye contact queues from the other musicians, and where I am on stage. When programming, I have to solve a problem with a blank canvas by creating and evaluating different pathways to the solution. Others might choose a different path completely or use a different language, but we end up with something that accomplishes the same goal in the end. Sometimes I have to sleep on a problem before I am up to come up with a solution. You can't just brute force your way through tough programming problems they require creative thinking. You have to weigh the values of readability, how to abstract and encapsulate things, and how to organize and structure your source code. All of those things require creative thinking and judgement skills to come up with 'the best' answer and even then people will disagree on that subjective measure. The design principles used don't have a right or wrong but more a stylistic preference and a creative person may come up with a very elegant and easy to understand way to abstract an idea that no one had thought of before. Think about the range of programming languages and design patterns. Think about how differently Haskell and Java express the same ideas or how different CGI scripting is from using MVC framework to do web programming.

The Learning Process

Both are things you can start very young, but spend your while life improving. There is no limit to what you can accomplish as people are constantly pushing the boundaries of what we thought was possible both creatively and technically. Both teach you lessons in starting small and progressing incrementally. The cumulative knowledge becomes apparent over time. As you reflect on your progress, you will encourage and motivate yourself based on the noticeable progress you have made. Both require large amounts of deliberate practice and are not an innate talent. This is true for just about everything in life though. The book Peak1 dives deep in to the research showing how important focused and deliberate practice is to any skill. Some people make the mistake of equating repetition with practice.

One of the best ways to improve is to learn the classics. For programming, this means cloning existing programs as a learning exercise. Beginners can clone programs like ls and pwd and eventually Pong and Tetris. In pop music culture, we call it learning "cover songs" and in other contexts it's called repertoire, but they are both just songs that a performer knows how to play but did not write themselves. I don't think anyone would expect someone to compose their own music before first learning how to play the music of others first.

Personal Development

Music and programming are both forms of creation and self expression. When starting out, musicians get nervous about performing and sharing their recordings. Beginner programmers have the same kind of stage fright before posting their code on GitHub. When practicing, you learn to identify your own weak spots, which requires being honest with yourself and dealing positively with criticism. It builds self esteem and confidence. You also learn what it is like to "be in the zone". Perfectionism is a characteristic that commonly forms, but I think it is simply an acute attention to detail.


One interesting find is that music and programming both utilize the language center of the brain. One study used brain imaging to see the effects of programming on the brain and found it had less in common with math and more in common with the language portion of the brain.2 Johns Hopkins University's School of Medicine did a brain imaging study that shows how jazz musicians activate the language portion of their brains.3 Stanford also reported how musical training helps language processing.4 Judith Barker found children with down syndrome improved language development by singing.5 Another publication discusses the effects of music on early language acquisition. They describe how children learn language as a musical performance first and look at the musical aspect of it primarily.6 There is also a publication from Georgetown University Medical Center about music and language using the same brain systems.7

The Time Factor

There is a time element involved with both of these art forms. The written forms of music and source code are only representations of the final product. They are only abstractions of a video game or of a symphony. Source code and music must be executed in a specific order in time. They only really exist for the time they are being run or played.

In addition, programmers and musicians must focus on the micro and the macro at the same time. They have to understand and pay attention to the small details while maintaining their place within the larger structure. They both rely heavily on temporal-spatial abstraction in the mind.


There is a similar modularity when comparing motifs, melodies, choruses, objects, and functions. Pieces can be rearranged, modified, and re-used. Not only within a single program or song but across many applications.

Communities and Trends

Music and programming can be both simultaneously an individual and collaborative effort. There are many different stylistic approaches and interpretations of the same goal. We see trends and evolution among programming frameworks, libraries, paradigms and languages just like musical genres, styles, and instruments. Enthusiastic communities are form around these different ideas.

The Danger of Teachers

Both music and programming can be and are often self taught. People who are self taught are generally pretty successful as they have one of the most important traits: self motivation. Couple the enthusiasm with a great teacher, and the potential is amazing. When you introduce a teacher though, there is a big risk. A bad teacher can take a neutral or even enthusiastic student and turn them off for life. Poor teaching methods and lack of enthusiasm will leave students discouraged. Unfortunately, I think it is rare to find a teacher who is enthusiastic, has developed a solid teaching method, and understand the needs of students.

Particularly, when absolute beginners are introduced to programming or music I think teachers spend too much time trying to run drills on tedious tasks instead of teaching something useful and fun from day one. It reminds me of the Karate Kid where Daniel was told to paint the fence and wax the car and becomes demotivated almost to the point of quitting because he did not see the importance or relevance of his tasks. How many times did you hear someone in math class say, "When am I ever going to use this in real life?" It can be an effective method of teaching for a student who already has the motivation and desire to persevere, but most people want to explore programming and music to get a taste first and see if they want to continue. For this reason, they should be hooked on day by doing something satisfying and practical. Work backwards from there to explain the underlying logic and structure.

Teaching Methods

For music, I think a beginner should be taught how to play and participate in music from the first lesson. If they are learning the guitar or piano teach them one chord and have them play it repeatedly slowly and steadily. The teacher should then "jam" with the student. Play some melodies and leads over the students rhythm. While they are only repeating a simple chord, they are an important part of the soundscape, and they are participating in the creation of the beautiful melodies of the teacher. This way, on day one, the student is having fun and feeling like they are contributing. From there you can explain what the chord is and how it works and begin to introduce them to new chords. For learning piano, I found a course8 on Udemy and the teacher, Robin Hall, teaches in a way I think is very effective.

For programming, I think a student should be taught to write some practical and useful code on day one. One thing that almost everyone will find useful is performing an HTTP GET request for a URL. Show the student how to make a simple request and print the response out. It is true they may not understand all the details or what is going on under the hood, but it is important for them to see how much work can be done with just a few lines of code. Explain how you can take it a step further and start searching for information within the web page so they understand some of the possibilities to get their imagination going. Work backwards and explain what is going on. Explain how they are creating a variable to store a value and calling a function to do some pre-defined task. They will be able to grasp these concepts better when they have some context.

I have a learning method I recommend for programming. It is good for beginners learning their first language or veterans learning their 12th language. Like building a repertoire of music, an aspiring programmer should build a cookbook of reference material and reusable code. You can read more about The Cookbook Method and check out the YouTube playlist for Learn Python - Build a Cookbook. The video playlist is intended for beginner programmers to get up to speed and learn enough to do some of the more intermediate and advanced tutorials on DevDungeon.


  1. Peak by Anders Ericsson and Robert Pool(book) -
  2. Understanding Understanding Source Code with Functional Magnetic Resonance Imaging -
  3. The Musical Brain: Novel Study of Jazz Players Shows Common Brain Circuitry Processes Both Music and Language -
  4. Musical training helps language processing, studies show -
  5. Singing and music as aids to language development and its relevance for children with Down syndrome -
  6. Music and Early Language Acquisition -
  7. Music And Language Are Processed By The Same Brain Systems -
  8. Pianoforall - Incredible New Way To Learn Piano & Keyboard -
  9. Cookbook Method -
  10. Learn Python - Build a Cookbook (YouTube) -