DEV Community

Cover image for Should you listen to music while you code?
Simon Pfeiffer for Codesphere Inc.

Posted on

Should you listen to music while you code?

Written by Dan Parry.

Listening to music while coding is a topic I often find myself talking to other developers about and everyone seems to have a different opinion or preference. Some don't like to listen to anything, needing silence to really focus. Others are into 'chill beats' to help them find their flow, and one maniac I know can code to black metal (he's from Finland).

Alt Text

It's all subjective! What works for you might not work for another but the reasoning is always the same - it's about finding a state of focus, creating an environment that minimizes outside interference and allows you to fix the problem at hand.

I am listening to music right now as I write this, just like I do when I write code. For me personally, and I believe many others like me, I find lyricless low-fi beats allow me to tune in and drop out the best. Songs with a lot of lyrics pull my concentration and distract me too easily. That's not to say my peers may not find Bohemian Rhapsody the way to go! What do you like?

For me, music can shut out the outside world and allow me to get lost in what I am doing, so much so that by the time I look up the music might have stopped already and I hadn't even noticed. But maybe you don't listen to music at all…

If silence is gold, why can't we sell it?

There is a strong argument that listening to music can be detrimental to true focus, stating that in order to properly process information the brain needs to analyze and retain instructions.

When listening to music, the added stress of processing audio data can cause the brain to misinterpret things or make mistakes. Which, I suppose, might explain any grammatical errors you find in my writing today.

This stance does line up with the global library ethos of "shhh! you're in a library" - people are reading and therefore a noisy environment is not good for them, so shut up or get out. Noise can increase stress levels, adversely affect the prefrontal cortex, and thereby lower productivity!

The counterpoint to this is of course that putting on headphones boils the myriad of sounds and distractions down to just you and the tune. Studies have shown that listening to music while performing repetitive tasks can increase productivity but again, it really depends on the individual.

Alt Text

A place for my head

Music or audio input, in general, can prevent the mind from wandering off and create a space for the mind to reside in.

I listen to music when I work for example, but I listen to audiobooks when I run - a practice I highly recommend to any runners reading this that haven't tried it. When I am in control of the task and I am required to exercise my mind, non-intrusive music provides me with a space to do that because it removes external distractions without introducing new ones.

When I need to shut my brain out or otherwise distract it while I do something that it's not really needed for, an audiobook is a perfect babysitter for my short attention span. 

It's all about finding how to harness the potential of your mind. What environment provides the best conditions for you to focus yourself on the task you're completing. Deep focus itself is a fascinating topic and one we will discuss another time because it allows you and coders like you to fully explore an issue or topic at hand.

You will be surprised at just how negative the effect of moving from one task to another can be if they require different emotional sensibilities to complete. Moving from writing code to writing emails requires an entirely different part of your brain to do and can result in you achieving neither as well as you are really able to.

Developers that are able to truly focus on the same issue for a long time with no distraction, to deeply focus, are able to find a state of workflow that the rest of us would envy if we could only experience it. 

Sonic youth

Gone are my teen years of MSN messenger and LimeWire when I would listen to obnoxiously loud music while surfing the internet and writing essays for school. It may be that the input of information we are exposed to has grown so much when we are online that the role of music has changed from a distraction to a blocker.

It is true the genres of music I listen to while I work have changed dramatically in the intervening years. There is no accounting for taste but as I mentioned earlier I write now to non-intrusive instrumental music, but I wrote my dissertation to Metallica.

There may be a case that my adolescent mind was better at multitasking, but I think the evidence is clear that complicated tasks require a clean backdrop for the mind to be set against, and music (or silence) can provide that. The overwhelming amount of "music to code to" videos on youtube in this style would support this theory.

Alt Text

That being said, I can still code, run, eat or sleep to Tool.

Ok, listen to this…

I will leave you with a piece of information I have been thinking about ever since I came across it at university over a decade ago…

A man was placed in an anechoic chamber, a specially constructed room that allows no sound in or out, he reported hearing a high pitched and a low pitch frequency. The low pitch frequency was the blood rushing through his veins and the high pitch frequency was his own nervous system.

All living things will experience the same and seeing as no electronic device can record true silence without some level of electronic feedback. So it would seem to me that there is no such thing as silence anyway…so you might as well stick a tune on while you're coding.

What's your favorite music to code to? Do you listen to music at all? Maybe you totally disagree with everything I've said, but that's ok, it's subjective. One man's music is another man's noise, so find your focus!

Happy coding from your good friends at Codesphere, the next-generation cloud provider.

Top comments (3)

jeangruneberg profile image
Jean Gruneberg

either lo-fi hip-hop or anything by aim to head on youtube

whirl profile image

i like to listen to raps while programming but my computer does not have enough power to support 5 language packs + fully customized vs code + spotify + discord so i end up closing spotify😁

pramon18 profile image

Sometimes podcasts, or any music in my library.