Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Trying to code and listening to music falls under cognitive functions. Naming a variable while listening to your favorite songs' lyrics may result in cognitive overload. You are more likely to name a variable after the singers/songs name than what the variable is supposed to reflect (true story).

This point in the article lost me pretty quickly. My flow state is drastically improved by music, and I have never ever named a variable after the song name or song artist I'm listening to in my life.

Edit: Nor have I ever seen a variable named after a song name or artist.

Edit2: NotoriousViewController. TheWeekndTimer. RedHotChiliPointers. Now I want to name my variables like this.



There was a semi-famous study (one that I feel every developer should have at least considered) that gave software developers a problem to code in the form of some convoluted set of steps, and they were either assigned to listen to music or not to listen to music. There was (usefully) no difference in the correctness of the implementations, but people who listed to music reported more subjective happiness / less boredom doing the task... only... they were also much less likely than the people who did the task in silence to notice that all of those steps collapsed down to "return a constant number".

I personally feel like there are different components of my brain and some of them just want to do something, and if I don't "distract" them then they do something arbitrary and maybe in turn distract me... but if I need them, and they are busy deciding some music I am listening to, I lose out on the maybe-even-often subconscious processing they do that gives me valuable insight. I thereby find some (mostly useless) tasks easier if I am seriously even playing a video game with a targeted skill while doing them (people hate me in meetings sometimes ;P), or maybe listening to music, but if I am doing the hard coding work I "should be doing" I just can't :(.


I was very curious to find more info on the constant number study. So far I found this older HN post, which is itself quoting from an apparently famous book, which according to some replies was BSing the whole thing https://news.ycombinator.com/item?id=1995239


I couldn't find anything on a study at Cornell University, but I did find mention of a study at the University of Windsor that included 72 students in three groups: a control group, a group that listened to music before, and a group that listened to music before and during.

The results[2] are published in an article behind a paywall, but they give details of the two tasks presented to the subjects, neither of which involved actually writing code. One was a 15-minute task of locating syntax errors, another was a 20-minute task of locating logic errors.

[1]: https://www.gwern.net/docs/music-distraction/2005-lesiuk.pdf [2]: https://www.tandfonline.com/doi/abs/10.1080/08874417.2000.11...



For me it depends on if the music has lyrics or vocals in it. Someone speaking or singing is the factor for whether my brain expends cognitive effort in listening. I just can't help but try and pick up on words and discern what the meaning of them are.


I actually have to get even more specific than this (at least prior to being diagnosed with ADHD in 2020 and getting Vyvanse for it).

If I need a mood boost or something to get my body "moving" in my seat and keep me from mentally wandering, I'll throw on stuff I really know and love. Usually I'm doing menial tasks or simple coding.

If I'm having a hard time focusing and need a distraction for some parts of my brain but not all of it, I have a "deathcore" (really more like melodic (tech) death metal) playlist where most of the songs sound very similar and you can't understand a thing the vox are saying.

Typically if I'm super tired AND need to block out the outside world but even hard to understand screaming won't cut it, I have to resort to either instrumental metal or LoFi hip hop beats to study to.

If I'm currently listening to music, I really only do a full stop/pause to focus if I notice I've run a breakpoint three times and have no idea what I've been stepping thru, or if I'm trying to refactor or write a fresh, new logic flow and just can't get my brain focused enough to "check it" for all possible paths. That's when I cut the feed, double-time my focus, and once I'm convinced it's "safe" I can hit play again.

Brains are weird and finicky I tell ya.


Do you notice your musical tastes at a given moment are modulated by Vyvanse levels? I find as I ratchet up the dose, or get very deeply focused on a task, the complexity of the music I listen to goes down. Morning, before the meds kick in, I like high-complexity high-energy stuff: eurobeat, electroswing, hard bop. That gives way to psytrance, then house, then techno, with high-tech minimal being my go-to when I am really firing on all cylinders. Then into lofi, downtempo, ambient, then silence for when I'm overstimulated.


For me, not being a native English speaker, it "feels" much easier to listen to music with English lyrics while working effectively on other cognitive tasks like coding, compared to listening to music with vocals in my native language.

On the other hand, there are several other factors, like how tired I am, how hard the foreground task is etc., so it is hard to pin-point it specifically to the lyrics language.


This 100%. I don't speak Spanish, but my god, Latin pop just gives me the flow.


For me it's how long I've been doing it.

If I've just started both are probably going to be good results. If I'm 4 hours in the music one will probably do better because I've not wandered away from my desk distracted by a shiny pen.


I've found for this reason I can never listen to new music I'm excited about when coding (i.e. a new album release by an artist I like), but I can listen to the radio and music I'm already familiar with without an issue.


Same for me. I can't code as effectively with lyrics in the music. Postrock hits the sweet spot for me.


Do you have a link or pointer to the title/org/authors? It sounds interesting and I'd love to read it myself. Absolutely I definitely feel like I'm not reasoning as well as usual when I've got something on.

[ETA]

According to [1] it's described in "Peopleware"[2]. Apparently needs corroboration (see sibling reply by 'civilized)

[1] https://www.quora.com/Does-listening-to-music-while-programm...

[2] https://en.wikipedia.org/wiki/Peopleware:_Productive_Project...


I wonder if that depends on whether the programmer gets to choose the music or not. I often hear music I know backwards and forwards or just straight up instrumental but if you put the pop 100 on I would get distracted.


This is something I have noticed as well, if it is music I've heard many times before it is far less distracting than something more novel.


Reading about this study and the experiences described in other comments, it seems the experiment is a bit limited in its scope.

The effect of music depends on the person, the type of music (lyrics or instrumental - even if there is applause or not), how well the person knows the music and, of course, the task itself and its complexity.

Until there's a way to test all of those permutations, I think the best we are going to do is rely on all our anecdotal evidence, as it affects ourselves.


This is similar to the experience of driving a car and listening to music at the same time. When you are in a tight situation, like a very busy road or a narrow street with lots of traffic you'd usually stop talking to the passengers or turn the radio down a bit to "concentrate". It's because you want to use all the mental capacity at that time.


Did the group without music have kids screaming in the background? Cause if they didn't, I'm not sure it is a realistic experiment.


It depends for me, if I am working on a tough logic problem I usually have to turn down any music with lyrics or high complexity as I will try to focus on the music instead. Otherwise it helps me stay focused by catching my moments of distraction, like a baby sitter for my brain.


I used to use music this way, until I started noticing that when I really got into flow I wouldn't even notice if the music stopped for hours. Then I started using white noise, and eventually just stopped relying on any kind of audio aid at all. Unless you work in a noisy environment you can train your focus.


Yeah, if I am really focused I won't notice if music is on. Music is only helpful for mind numbing/very boring tasks. And helpful that those won't feel as boring, not making me do things better.


Same thing for me. If I have a novel problem I am trying to solve, then I'll usually turn down (or off) the music. If I'm refactoring or the problem is well understood and I'm just typing, then I vastly prefer doing it with music on.


Can confirm this. I can't have music if the problem requires a mental dialog, but it's helpful for rote or visual tasks.

(Also happy hardcore makes a passable coffee substitute/addition.)


> if I am working on a tough logic problem I usually have to turn down any music with lyrics or high complexity as I will try to focus on the music instead.

This is similar for me. The worst are live recording with applause and interactions with the audience from a show. While I can fade out lyrics it's close to impossible to ignore these.


Yeah usually for hard problems I need to talk myself through it. Talking while listening to music just overloads me.


For me the difference is I can listen to music I already know while coding, but listening to NEW music with lyrics requires much more cognitive load.


+1. I suspect many of the "I could _never_ listen to music while coding! The horror!" people are those who listen to "radio" or "playlists" they are unfamiliar with. While I almost always listen to a full album, start to finish, that I know well.


+1 the part with a full album is also really important. Even better when you get into operas and stuff because then you can have a good few hours in one go.

edit: also if you make a playlist made of a chronological listing of one artists full albums.


And to me, it's the exact opposite. I can't code while listening to well known music with lyrics but I enjoy listening to some electronic house music while coding. Music I usually don't listen to.


Came here to say exactly this! Tried a new album but that overloaded me totally. Then I went for an album I've listened to for a thousand time or so and got into the zone directly.

I've read somewhere that humans language processing centra only can deal with one input source at the time. So reading and talking is more or less impossible to do at the same time.


My experience is different. I'm not a native speaker and if I listen to music in English, usually it just fades into background. I rarely experience it. In that way I feel it does not have any effect on me, but obviously it's anecdotal and I don't have any real data.


Not all music is the same. One music will help with the flow, other will disturb it and make you name vars after songs, and then there is music that makes you put your tasks away, go to that person who is listening to it and have a serious constructive conversation about how not listening to it could greatly improve their relationship with you and other people who are trying to concentrate on their job instead of imagining that person in a hell fire.


Beautiful prose. Well constructed.

I cannot stand the "out loud" variety of music when I'm working, at least.


As it turns out, people have differently structured brains. I cannot write code and listen to music at the same time, for example.


>As it turns out, people have differently structured brains.

Or maybe some just dellude themselves (and e.g. lose congnitive capacity with music, but conflate their hapiness boost for increased productivity, etc.).

This "differently structured brains" was the once popular idea behind different "learning styles" (visual learner, etc.) who has been discredited since.

Evolutionary it's more probable we have quite identically structured brains when it comes to main functions, and just have different e.g. cultural tastes on top.


Aphantasia would be a good example of clear differences in how people's brains operate (and one that anecdotally seems to be not that uncommon among programmers). Given that it only has gotten real scientific attention in the last 10 years it doesn't seem unreasonable that other major variations exist that we don't know about yet.


"Learning styles" are a great example IMO of non-scientists taking an idea with some merit and running away with it, to the point that scientists stop investigating it pretty much altogether because it's been branded "pseudoscience". Yeah the term learning styles itself is probably at this point a red flag for education pseudoscience, but the idea that different people may naturally solve the same problem in different ways is still very much an open question. It is probably true to at least some extent (as can be seen in certain extreme examples e.g. non-verbal vs verbal specific learning disorders).

Another example of this broader phenomenon is galvanic skin response. People ran with the lie detector BS and then the whole field basically died for a few decades, only to eventually be rebranded "electrodermal activity". Probably your smart watch will be collecting EDA in a few years.


There is a great interview with Feynman where he recounts that he could count while reading, and a colleague called shenanigans. So, they did some experiments together. Fun watch, but seems in contradiction to your point. :(


If I recall correctly he talked further about this in one of his autobiographies (Surely You’re Joking, Mr Feynman possibly?).

It was about the repeatability of counting to a minute, and he experimented on the difference between seeing a timer tick in your minds eye and hearing a count increment in your head.


It was What Do You Care What Other People Think?.

He had been experimenting with what he could do while counting, and found he couldn't count while talking, but could count while reading. John Tukey didn't believe him, and thought it should be the other way around. It turned out Tukey and Feynman counted completely differently, Tukey by visualising and Feynman using internal speech, and so Tukey could count while talking, but not while reading. So, not the same person doing both methods.


Wait.

1) You don't think people have different learning styles? 2) You don't think that I know what distracts me while I'm working? 3) You don't think that evolution produces _vast_ diversity, and that people have vast differences in brain structure?


Before COVID, music was certainly less distracting than practically available alternative, everything being said on your office floor.


I prefer silence also, but even music with lyrics was better than the sales guys cold call pitch, somehow that absolutely SHATTERED my flow state without fail.

Strangely enough I find working in the "white noise" of a coffee shop lets me hit flow state even better than silence. Not sure if thats more due to the "i'm in this place to do the thing" effect or the actual noise though.


See, this one does not bother me. Indistinct chatter / noise does not distract me in the slightest. In fact, that sound is actually a great environment for me to focus - total silence can actually be distracting for me.

Music on the other hand, I cannot program while listening to. Brains are different.


I had exactly the same thought.

I suspect there is a personality difference in play where some people find themselves trying to analyse the music, so it acts as a distraction for them. Compared to them, I sink into the energy/rhythm of the music and it helps drown out other distracting noises.

It might also depend on one's playlist. Some people like having a TV on for background noise, but I would find that highly distracting. My playlist leans towards highly energetic music where there isn't much reliance on lyrics, such as technical death metal.


Just from your replies people can see that many people can code with music, and many only with silence.

I think this is something CEOs don't realize when they push for ,,open offices''.

For me a group of 5 people in a room was the optimal number of people for coding enjoyment: just enough people that I feel the pressure and don't feel alone, but not too much noise, so I can work well. For people who can work with music an open office is still kind of OK, even if they don't like it that much.


Open offices are terrible if you want silence, and only kind of ok when you want music (you can make it work with noise cancelling headphones turned up loud enough). Both types would be better served by smaller offices.


Music is the only thing that saved me in an open office. Without it I would be hard pressed to ever find flow. I’ve been distributed for almost 2 years and the combo of music and no one else in my office has improved my output a ton


When I first started, I was in a room with 8-9 people who knew each other well. They talked a lot. I was given a task that I found challenging but the most challenging part was focusing on the task at hand.

My solution was to listen to one of various white noise videos on YouTube, my favorites were storms and rain.

I agree that about 5 people in a room is a perfect fit. Team sized. Open spaces were too distracting.


Do you listen mostly to music with lyrics or accoustic music? I find the latter helpful but the former quite unhelpful - like trying to do math when somebody next to you is shouting randon numbers. But I have a faint recollection of having read research on this where it depended if you were a visual/verbal/etc thinker, and you were more vulnerable to disruptions occurring within your given thinking method.


I have perfect pitch and find it impossible to "turn off" the analysis of music - what key is it in, what's the chord progression, and so on. Whether it has lyrics or not doesn't matter, it completely kills any productivity in any other cognitive activity. Only "noise" type sounds work for me when I'm trying to concentrate, like recordings of gentle rain or a babbling brook.


I listen to all sorts of music and it doesn't really change much. Realistically I tune out of the lyrics while I'm focused on something else anyway.


For me, it depends on how familiar I am with the song—if I've heard it a thousand times, the lyrics fade into the background for me. But if it's a new song, for example, my concentration plummets.


I have the (somewhat) opposite problem of needing to concentrate to hear the lyrics of a song. By default the lyrics fade into the background and I only notice the beat and/or musical instruments.


I'm the same way.


“The radio was a clue. You can’t really think hard about what you're doing and listen to the radio at the same time. Maybe they didn’t see their job as having anything to do with hard thought, just wrench twiddling. If you can twiddle wrenches while listening to the radio that’s more enjoyable.”

Zen and the Art of Motorcycle Maintenance.

I sometimes listen to music while coding, but for me it only really works with something like Aphex Twin or Autechre. Something that puts me in a meditative state - almost like white noise. And usually the purpose is to help block out surrounding noise. I’m with Persig on this one — when it comes to deep concentration, I tend to prefer quiet.


I remember seeing an article about something related to this some time ago. When it comes to music and background noise in a work environment, the nature and kind of noise matters greatly. If you don't have the right kind of noise for the person and the situation, then it can be more harmful than helpful. Wish I could find that article...

Edit: I think this might be it: https://www.bbc.com/worklife/article/20191115-office-noise-a...


> This point in the article lost me pretty quickly. My flow state is drastically improved by music, and I have never ever named a variable after the song name or song artist I'm listening to in my life.

Yea, this is highly dependent on the person. I have difficulty in life operating _without_ music. In anything, really. My brain wanders, i start making music, etc.

Worse yet, i find silence while programming to be stress inducing. My shoulders get super tight, and i'll find myself in a trance an hour later, super tense and feeling like i'm waiting for a bomb to drop.

Music is my emotional regulator. It lets me mirror where my head is. Chill, aggressive, grinding, etc.

The only time i find music to be a distraction rather than a method of focus is if the song is too new to me, is heavily lyrics based, _and_ i really enjoy that authors lyrics. I tend to want to focus on the lyrics, learn them, understand them, etc. Most of the time though lyrics are just yet another sound, and they vanish into the fog of work for me. I often even lightly sing while i'm programming (I work from home, lol).

edit: Oh, i should add though - this whole post of mine represents the .. maybe 80% use case. I do turn music down when i'm thinking about a challenging problem. Something i need to hyper focus on. But that's only 10-20% of the time for me. Most of the time i have a clear picture about what the general design is, and now i just need to write out the internals.


I prefer listening to music too, but here's the thing: I can only listen to music that doesn't have lyrics. The moment lyrics enter the picture, I start having a lot of difficulty concentrating on the problem.

This is why I listen to techno, retrowave, instrumental jazz and classical music when I code. I leave hard rock, metal and pop music to when I'm not coding.


To me I think there are two "parts" to being in the zone.

Say depth and duration.

Depth is kind of like how many digits of a number you can memorize.

Duration is a little like endurance in a race, but a little like tying yourself to the mast too [1].

I get much deeper into the zone without music, and I also stay in it longer.

Might not be as fun, but for me, I know this without a shadow of a doubt.

[1] ironically, odysseus tied himself to the mast to listen to music.


I've found that listening to music with lyrics is indeed problematic with tasks requiring focus. Luckily there's a plethora of electronic music genres without any spoken words :)


at least for me, the trick is to listen to music in a different language than you don't speak(in my case Japanese), since you won't understand a word you won't lose focus with the lyrics


Completely agree.

Thinking about it, though, I find myself reaching for music when it feels like my mind wants to wander and not focus on my job. Once the music is on, my mind has an immediate outlet for wandering - it jumps to the music while I'm still looking at the code. So while maybe music and programming do compete for resources, music maybe acts as a sort of safety net that makes it less likely for me to derail completely.


di.fm has served me well over the years while coding. Being able to listen to something without lyrics or a major cognitive load works quite well for me.


I used to listen to them as well! I do prefer less lyrics, or more rhythmic lyrics, but I can do normal music as well, personally. That specific example of why it was a problem just amused me.


I agree, I really enjoy music and find it helps me get into a good flow. However, for me at least, it needs to specifically be music without lyrics. Downtempo electronic is usually best, but I can make pretty much anything work so long as it’s not music that one can “sing along to.” In that case I often end up humming along to the lyrics and getting distracted.


Its almost impossible for me to code while listening to music while coding in a high-cadence big-brained language like Python. When I do c, Java or markup like HTML less so. Perhaps this has to do with the fact that Python is very succinct, and you can affect more per line than in "dumber" languages.

Music with lyrics is impossible to code to though.


Not all music is made the same. The quote mentions lyrics — indeed lyrical music can be distracting. However, I think, as in exercise, music can boost productivity if it aligns well with the activity, e.g. provides enough space to think in coding while enhancing mood, pace of thought, and focus.


Exactly! That's why I prefer listening to instrumental music when coding.


The author lost me there too. I think the general experiences for many of us here is: you can't listen to music that occupied the same cognitive channel of what you're doing.

If you're thinking, writing, or planing(or anything with 'words' in your head or 'talk' to yourself), music with lyric is bad (though I found the effect more soften a bit if you listen to what you don't understand, e.g. foreign language music, still, zero lyric is crucial for thinking)

If your activity is not about words, but more 'action' (e.g painting , making art, gardening) then you can blast your ear with lyrics or the whole audiobooks all you want. It works great.


The variable naming thing seems like total bullshit but when I find a song I like too much I find it can be distracting. When I'm feeling most productive I hardly notice the music thats playing.


I've found listening to brown noise actually makes me so much more productive than music.


To me it also makes a difference if I understand the language used in the lyrics or not, so I prefer to listen to languages I don't understand but like the sound of while coding.


Tangential to music, but how do y'all train yourselves to ignore your bodies? I sit for 5 minutes and my back hurts. It's my biggest focus killer. I'm constantly aware of how physically uncomfortable I am when I have to work on some extended programming task, sitting or standing desk alike.

I've taken to lying horizontal with a keyboard on my lap and a projector aimed at the ceiling. Feels ridiculous but it's at least comfortable.

Sometimes I don't think I'd mind being a brain in a vat.


If you're that uncomfortable after trying to adjust, it sounds like something might be wrong. Could be worth asking a specialist about your symptoms.

I occasionally have RSI issues, which are usually a stress symptom telling me I'm operating above red-line. If I listen to my body, things work out much better than if I try to ignore it.


Have you looked into yoga, Pilates, or any core strengthening exercises? While sitting is very strenuous on the human body, it's not something that should hurt after five minutes.


Sounds like you need to do core exercises: crunches etc.


"music" is also a very broad term. There is complex music you don't even grasp without paying attention and there is music that is designed to get your attention and start dancing.

Music helping with your flow status might be related to it blocking external noise. I have similar results with (some type of) music, earplugs or white noise.


I mostly agree based on my own experience, I rarely get distracted by the lyrics alone, what gets to me is bass. Whenever a bass-havy song comes on I feel like my focus breaks, which is also why I started to listen to more jazz and similar, more easy going, genres while working and needing my focus.


It depends on the type of music. Music with lyrics (like mentioned in the article) is very distracting for me, but some types of instrumental music (like videogame soundtracks) work very well.


I counteract this by exclusively listening to music in a language I don't understand when working. Really reduces the cognitive load when you don't have to process the meaning of words.


Listening to songs that i know lyrics of are far more intrusive than the ones that i am not familiar with our are completely new.

I generally listen to lofi music while coding. Increases my focus for some reason.


There is a competition for resources while listening to music. I think this was talked about in Code Complete, book I read 20 years ago.

Its just damn pleasurable to do!


If music makes you less focused, I feel sorry for everyone working in physical stores and getting WHAM:ed every day for weeks leading up to Christmas.


I have legacy code I look after with variables like $bjork


My flow state is drastically improved by music

People when multitasking usually believe they are being hyper efficient but when observed from the outside they are less so than when single-tasking sequentially.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: