Hello! Today we will discuss the concept of beauty in programming.
Let me ask you a simple question: what makes a code beautiful?
Try thinking about this question (at least a little) before scrolling down.
You probably came up with a few characteristics: it’s readable and/or modular. Maybe it’s well tested. Or maybe it follows clean code principles or other familiar practices.
What if I told you that beautiful code is just… average code? That might sound silly, but let’s walk through it.
Attractive Faces Are Only Average is a foundational study by Judith H. Langlois and Lori A. Roggman in the psychology of facial attractiveness. They created composite images by averaging multiple individual faces—noses, eyes, cheekbones—all mathematically averaged.
These composites were consistently rated as more attractive than the individual faces used to make them. In fact, the more individual faces were averaged into a composite, the more attractive the resulting face became.
This suggests that facial features close to the population mean are generally preferred.
Why? The main theory is processing fluency: the easier something is for our brain to process, the more we like it. Average faces are easier to recognize and interpret, so they feel more pleasant.
This principle doesn’t stop at faces. It applies to advertising, art, or even decision-making. When something is easy to process, brain imaging studies show that it activates reward-related regions. We enjoy it more, without even realizing why.
So what happens when we apply this principle to code?
It means that the more average the code is, the more it aligns with what we’ve seen before, and the more beautiful it feels. The less surprising it is, the more pleasurable it is to read, understand, and maintain.
How can we write average code?
Use standard naming conventions: Stick to familiar names so others instantly know what things are.
Follow language idioms and common patterns: Write code the way others expect it to be written.
Favor clarity over cleverness: The easier it is to read, the more enjoyable it is to work with.
Be consistent: Predictability makes everything easier to understand.
Minimize unnecessary novelty: The more our code looks like what we’ve seen before, the faster it gets processed and the more it’s liked.
Beautiful code is the kind that conforms to established patterns, idioms, and norms. It’s not flashy, novel, or overly clever. It’s clear, familiar, and quietly elegant. Just average.
What if next time, the best compliment your pull request could receive wasn’t that it was “brilliant” but simply “average”?
💬 Does this idea resonate with you or does it feel wrong? Curious to hear your perspective.
❤️ If you made it this far and enjoyed the post, please consider giving it a like.
📚 Resources
More From the Software Engineering Category
Sources
Attractive Faces Are Only Average // The study mentioned in the post.
Your Code as a Crime Scene // I read about this study from this book.
Very interesting analogy with the attractive faces, Teiva. I would have said that code beauty is mainly related to its readability, to its literal beauty. And also related to the problem it solves, and it’s context…but you convinced me finally :)
Great read! Do you think designing "average" code usually requires more effort and time? Especially with creating concise, readable code?