Does being happy make you better at coding or does coding make you happier?

Małgorzata Kuś
Aug 26 · 6 min read
Photo by Austin Distel on Unsplash

TL;DR

It’s complicated, but there does seem to be some evidence that the more negative a person feels, the better their problem-solving performance is. Feeling bad, however, has a detrimental effect on productivity and motivation, while good emotions push you forward and make you slightly more creative. Way to go? Flow and more research.


Human Factors

Let’s dig into more details.

The room is dim and silent. The person sitting at the desk is only visible because of the faint light given off by a couple of large screens. Half-empty mugs are uninterested witnesses of the creative process. Behold—a programmer at work.

However magical feats of software programming may seem, especially to a layperson’s eye, programming, just like creative writing, playing chess, or painting, is yet another complex cognitive activity that can be studied by psychology. And there are indeed people who focus their work on what is called human factors in software development: moods, emotions, preferences, and their effects on the quality of devs’ work.

So what is software engineering to a psychologist? A complex skill that requires two different capabilities: creativity and analytical problem-solving. To be successful and write great code, programmers need to be able both to generate many good ideas and to get to the point—find the solution, or at least one that works.

So there we have it: Being creative and solving complex problems fast and for good is what will make you a great developer. But are those qualities stable over time? What may improve the results and what has the potential to damage them? Or, as one could ask, do happy cows give more milk? Or are angry programmers the best programmers?


Effects of Emotional States

The connection between being happy, angry, or sad (formally speaking: affective states) to one’s ability to solve problems or come up with good ideas has been studied multiple times. It seems reasonably important for workforce performance.

Unfortunately, the results of studies and large metanalysis are quite unclear. Some studies do find that feeling negative emotions can be linked to improved analytical performance. Others, on the other hand, don’t see that link whatsoever. There is research indicating that happiness correlates positively with creativity on specific tasks. But that’s the outside world. Let’s get back to our dim room and a hooded figure bent over a keyboard.

I looked into two studies that focus on these aspects of human performance in strict relation to software development. Indeed, a multinational study group found out (based on a relatively small group of CS students) that those programmers who reported feeling more positive emotions were better at generating more ideas and that those ideas tended to be of better quality. In other words, if you’re stuck and feeling low on ideas, watching a happy cat video may not hurt your performance, but provided it makes you happier, it may even improve it. If that’s not useful science, I don’t know what is ;)

On the other hand, the same study found evidence that negative affect can foster critical and analytical thinking. Those who are feeling blue tend to question ideas and concepts more, doubt the existing solution, and aim straight for the answer. Could pissing off your colleagues every once in a while be good for the company?

Before we run away to throw things to annoy our coworkers, coding happily in the peace of their open spaces, let’s see another perspective. A differently framed study by the same authors has enumerated many unfavourable effects of negative affect in developers. This time asking them to make their own assessments. So whenever devs are feeling bad at work, they are also affected by:

  • Mental unease or disorder: As in any other human, being subject to negative feelings of panic, self-doubt, and frustration can result in mid- or long-term mental health hazards. We don’t wish that on anybody.
  • Low motivation: Resulting in opting out from new opportunities, passing up on ideas, working slower or not taking up new tasks.
  • Work withdrawal: Avoiding the task in question, taking on other assignments that appear easier or, when taken to the extreme, leaving the company.
  • Low productivity: Resulting in delays in delivering results.
  • Decreased adherence to the process: Cutting corners to just get things done and forget about it. Not checking whether the solution works as intended, not testing, not documenting, you name it. Just shipping the bloody thing and moving on.
  • Low-quality code: That’s not surprising when you look above.

Are all those things worth the slight increase in problem-solving that was mentioned earlier?

Because when you look at those who reported positive affect, they also reported opposite tendencies:

  • High cognitive performance: I can do it all! Easy.
  • High motivation: And willpower to continue coding.
  • Higher work engagement and perseverance.
  • Higher creativity (and we remember that it’s particularly important).
  • More strict adherence to processes.
  • Higher productivity and improved workflow.

As you can see, research is somewhat unprecise when it comes to measuring the effect of affect on software engineering performance. It’s hard to build on such shaky ground, so I’m not going to leave you with a helpful to-do list to make you a better coder. There are other psychological findings out there, however, that may come in handy.


It Touches Artists and Programmers Alike

Is happiness even something we should strive for at work? How would we define it, and what emotions would we expect to feel? Even those people who report being content with their job don’t usually mean they spend their whole days giggling, drinking coffee, and playing ping-pong. There is something else that does the trick. And it works also for seemingly different lines of work.

It’s already anecdotal how programmers need their peace and quiet to really get into the zone. But some time ago, and far away from a tech open space, a Hungarian psychologist noticed how artists get drawn into their work and lose track of time and space. He started researching it and later published a theory about what is now the holy grail of happiness at work: a state of flow.

Flow is a self-reported state of immersion and focus, resulting from performing complex tasks where the difficulty matches our abilities and challenges are welcome. To experience it, you need to be proficient at what you’re doing and work on a problem that is just the right amount of challenging. What happens then is not pure joy because those in the state of flow are so focused on the job they don’t experience many personal emotions. They are “out there,” immersed in the task and their own competence.

As we know from the life-long research of M. Csikszentmihalyi, people in the state of flow are indeed as happy as it is possible at work. But that is not all and by far not the only benefit. Research findings by a Harvard professor, Teresa Amabile, showed the positive impact of this state of mind: higher levels of productivity, creativity, and happiness last longer than the experience itself. Reaching the state of flow improved those qualities for research subjects for up to three days.

The effects of the state of flow are almost like a magical potion that, when drunk once, keeps you going for longer than a full weekend. The potion is just chemicals in your brain, brought to life by achieving a state when your action and awareness are merged, your attention is full, and the flow of time becomes irrelevant.

So, are those who are happier better at coding than the sad and angry ones? It’s hard to tell. We still don’t know enough about things that improve coding performance, and it could be useful to dig deeper. But those who continue to get better at writing code and are able to get in the zone are truly happy while doing so, and the effects on their creativity and well-being are long-lasting.

Good for you, happy programmers!


Sources

What happens when software developers are (un)happy, Daniel Graziotina, Fabian Fagerholmb, Xiaofeng Wangd, Pekka Abrahamsson

Happy software developers solve problems better, psychological measurements in empirical software engineering; Daniel Graziotin, Xiaofeng Wang, Pekka Abrahamsson


Bonus Info

Reading scientific articles never ceases to provide useful facts and quirky news. Based on one of the sources, the study confirmed that developers can switch from being happy to being angry in under 48 hours … Cheeky beasts. Such volatility of emotions. ;)

Better Programming

Advice for programmers.

Thanks to Zack Shapiro

Małgorzata Kuś

Written by

Interested in what happens when humans meet machines. Psychologist in tech. Curious about #HumanFactor. Communicating tech-related things at DreamLab.

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade