Friday is Coming! The Scientific Case for Why Programming is so Darned Satisfying

The process of solving a programming challenge turns out to follow The Hero's Journey story structure, a pattern our brains recognize and reward.

When I started learning how to code, I stuck with it because I enjoyed it and found the process immensely satisfying. I described it as solving puzzles all the time, which it is, but I never thought about it any deeper than that. And then, one day a few weeks ago, I was talking with fellow Sparkboxer Heather about the phases we go through when working on a coding project, and I had an epiphany. Having been a writer for several years—writing novels, short stories, essays, etc.—I recognized that the process of solving a programming challenge she was describing follows the Hero’s Journey story structure, a pattern that research has shown our human brains recognize and reward.

It’s Always Darkest Before the Dawn

The Hero’s Journey is a well-known, well-worn story pattern that has existed for as long as stories have existed. Joseph Campbell popularized it as the “Monomyth” in his book The Hero with a Thousand Faces. He breaks down the Monomyth—a story structure shared by myths from around the world—into three parts:

“A hero ventures forth from the world of common day into a region of supernatural wonder”

In the first part of the story, the main character is presented with a problem and has to decide whether or not to accept the challenge of solving it.

In Heather’s process, Monday is the first part of the journey. She picks out an issue to work on. She accepts the challenge. She’s excited, she’s going to get this figured out and it’s going to be great.

“Fabulous forces are there encountered and a decisive victory is won”

Once the main character accepts the challenge, we move into the second part. Now, our main character has to solve the problem but fails repeatedly. They muddle through, trying this and that, maybe asking for help, gathering knowledge about what works and what doesn’t. It is very frustrating. Sometimes the main character will get themselves so far down some dark alley they wonder if they’ll ever see the light of day again. But then, all the knowledge and experience the main character has gained through their struggles come together and they are able to surmount the challenge and save the day. Huzzah!

For Heather, Tuesday and Wednesday are part of the struggle. She’s facing problems she hasn’t solved before (as all programmers do, no matter how seasoned) and she’s digging in, doing a lot of research, spending some quality time on sites like Stack Overflow. Thursday, however, glimmers of light start to appear. And then Friday, that magical day, all of the stuff she’s tried and all of the stuff she’s been learning somehow comes together and voilá! The solution presents itself. The sun has risen, the birds are singing, and all is well with the world.

“The hero comes back from this mysterious adventure with the power to bestow boons on his fellow man.”

In the end, our character not only solves the problem but has gained something valuable—knowledge, maybe—that they can then share with their community and use to help others facing similar challenges.

This means that now that Heather has conquered her challenge, she is feeling great about her accomplishment and has knowledge she can share with her fellow developers, maybe as they work on similar challenges, maybe even as a post on the Foundry.

It’s All In the Pattern

So the process follows the Monomyth structure. What does that mean and what does it have to do with our brains? A lot, as it turns out. In the book Daring Greatly by Brené Brown, which I happened to be reading at around the same time as my conversation with Heather, she talks a lot about how our brains react to stories and the patterns they create. In particular, she talks about the research done by two scientists that shows how our brains recognize and reward us for completing this pattern.

Paul Zak, a neuroeconomist, has been able to show that just listening to a story, which Brown defines as “a narrative with a beginning, middle, and end,” will trigger the release of oxytocin in our brains. Oxytocin is known for increasing empathy and engagement in humans. As Zak puts it in an article about his research in the Harvard Business Review, “Enduring stories tend to share a dramatic arc in which a character struggles and eventually finds heretofore unknown abilities and uses these to triumph over adversity; my work shows that the brain is highly attracted to this story style.”

More directly related to my assertion here, though, the neurologist and novelist Robert Burton has found that stories—narratives with our three-act beginning, middle, and end—trigger the brain’s “reward system,” an imperfectly understood process that involves a rise in dopamine levels in the brain. According to Burton, it’s all about pattern recognition, which he describes as “the brain’s way of piecing together a number of separate components of an image into a coherent picture.” When you bring those components together—when you finish your story or solve your challenge—you are completing a pattern and your brain is rewarded. The dopamine and oxytocin make you feel good, happy, generous, and connected.

Friday is Coming!

So the next time you get stuck on a tough problem—maybe your JavaScript function isn’t producing the result you want or you can’t quite get that image to look right in different browsers—remember that Friday is coming. You may get stuck in the weeds a bit and you may even find yourself ready to give up. But, remember, it’s a pattern. We accept a challenge, we struggle, we overcome it, and then we feel great! So in the end, all the difficult fumbling and learning you’re doing will come together in a finale that will make you feel so good, you’ll be ready to share what you’ve learned and start all over again.