Talks

Summarized using AI

Aesthetics and the Evolution of Code

Coraline Ehmke • July 20, 2018 • Earth

In her talk titled "Aesthetics and the Evolution of Code" at the Paris.rb Conf 2018, Coraline Ehmke explores the relationship between aesthetics and coding practices, emphasizing the importance of elegance in software development. She begins by outlined her credentials as an open-source advocate and discusses her experiences in Paris, setting the stage for her deeper philosophical exploration of aesthetic theory.

Key Points Discussed:

- Elegance in Code: Ehmke examines the concept of elegance in programming, comparing it to the way beauty is interpreted in aesthetics. She discusses theories like pluralism, hybridism, and absolutism to illustrate how beauty can be perceived differently.
- Applied Aesthetics: She highlights how the principles of applied aesthetics can enhance the user experience in programming, urging developers to create interactive and pleasing code rather than producing 'brutalist' applications that merely serve functional purposes.
- Natural Selection in Code: Drawing parallels between biological evolution and programming, she analogizes that just as organisms evolve through natural and artificial selection, so too does code evolve. Projects that are elegant and well-structured are more likely to attract contributors, resembling an ecosystem's natural selection process.
- Aesthetic Qualities in Programming Languages: Ehmke presents her findings from a survey ranking programming languages based on aesthetic criteria, stating that Python performed best, followed by Ruby and JavaScript, suggesting a correlation between aesthetic appeal and popularity.
- Measures of Elegance: She identifies four main aesthetic principles that should govern code: correctness, performance, brevity, and readability. Each intersects to create an elegant code experience, stressing the need for balance among these elements.

Significant Examples:

- Ehmke contrasts aesthetically pleasing architecture such as Bacon's Castle with utilitarian brutalist structures like the flak tower in Hamburg, demonstrating how aesthetic principles can elevate functionality.
- She illustrates the evolution of apples through the story of Johnny Appleseed, emphasizing how natural aesthetics have influenced agricultural practices.

Conclusions/Takes Away:

- Developers should approach coding as a form of artistry, creating elegant, timeless solutions rather than merely producing expedient and ugly code driven by external pressures.
- The aesthetics of code are not just personal satisfaction but have practical implications for maintainability, extendability, and community engagement.
- Ehmke encourages developers to consider who their code is for, ultimately advocating for a return to craftsmanship in programming that thrives on beauty and utility.

00:00:11.380 Please welcome Coraline Ehmke! Hi, everybody! I judge the success of a talk by how many tweet replies each tweet receives. So, Coraline, please be kind and please be in English. I've been a web developer professionally since 1994. I built my first website in 1994, Paradise Faust, and I don't know if you can see, but it was one of the top 5% websites in the world.
00:00:21.910 Thank you! I've been doing open source since 2004. In 2016, I won a Ruby Hero award. I'm one of the founding panelists on a podcast called Graders in Code, which I encourage you to check out. I am most well known for being the creator of the Contributor Covenant, an open source code of conduct adopted by over 40,000 open source projects, including all of Google’s open source and all of Apple’s open source projects.
00:00:55.960 I'm also working on a book called 'A Compassionate Coder,' which is about the practice of empathy in software development. If you'd like more information on the book, please visit compassionatecoder.com and you can sign up for our mailing list to keep up to date on developments.
00:01:24.820 So, this is my first time in Paris, and I've been taking in all the sights. I’ve found that the locals are extremely friendly, and I'm learning how to understand important French phrases like 'Bonjour, je voudrais un café.' I’ve probably butchered that phrase, and I've been tweeting about the things I've learned as a tourist.
00:01:39.219 You’ve seen the #FranciaFacts hashtag, which is something I do in every country I visit. I find it fascinating how many Parisians get around the city on scooters. This trend began in 1987 when Parliament outlawed the ponies that were so popular until then, all due to the manure crisis. Okay, I’m here to talk to you about aesthetics and the evolution of code.
00:02:08.020 As programmers, we are captive to the notion of elegance. We talk about elegant code, but what do we mean by it? One of my favorite children's books, 'Alice in Wonderland,' has a scene with Alice and Humpty Dumpty. Humpty Dumpty says, 'When I use a word, it means just what I choose it to mean, neither more nor less.' The question is, says Alice, whether you can make words mean so many different things.
00:02:29.490 The question is replied by Humpty Dumpty, 'Which is to be master—that is all.' Well, it just so happens there is an entire science devoted to understanding beauty and elegance, and we're going to explore it today. It's called Aesthetic Theory. Aesthetics is the study of how we experience beauty and is usually defined as a sensory appreciation of beauty.
00:02:59.010 However, the appreciation of beauty can also be a cognitive phenomenon. Therefore, theoretical approaches to aesthetics include pluralism, which states that every person perceives things differently and derives different meanings from an experience. Consequently, there’s no absolute truth in perception. An example related to pluralism is if two people look at something blue; they’re both experiencing a unique color. There is no universal blue.
00:03:34.530 Then we have hybridism and hybrid perception experience, where the common representation is truthful. With hybridism, we might say everyone looking at the sky sees just about the same blue. In absolutism, aesthetic beauty derives from truth and provability, as the wavelengths of light reflecting off an object cause us all to perceive it as blue.
00:04:04.390 This school of thought emerged from applied aesthetics, and according to Dijkstra, it is the only one that applies to mathematics and thereby to software. Finally, we consider eclecticism, which promotes the application of different interpretations contextually rather than adhering to a single set of standards. With eclecticism, there are multiple paths to the truth.
00:04:25.400 The effects of our aesthetic sensibilities can also be deliberate. This is called applied aesthetics. Think of physical things in the world; they possess basic attributes pertaining to their physicality. We build structures designed to serve utility, comprising materials with fixed costs, but when we build buildings, we don't just create concrete boxes. Through applied aesthetics, by deliberately injecting aesthetic attributes, objects can be elevated to new dimensions, becoming not just utilitarian but also an expression and an experience.
00:05:09.220 This makes our interactions more pleasing. Both buildings serve a purpose, but one provides a pleasurable experience, while the other does not. We long to be surrounded by beautiful things, things that appeal to our aesthetic sensibilities. This is Bacon's Castle in Virginia, where I'm from. It was built in 1665 and is the oldest documented brick building in Virginia.
00:05:39.199 It has been maintained by private and government funds as a historic site for the last 300 years. This is a 120-foot tall flak tower built in Hamburg by the Nazis to protect anti-aircraft weapons and to defend against bombing raids by the Allies. It's made of poured concrete. Hamburg has very high property values, but this flak tower is built so robustly that tearing it down would cost more than the real estate it's on.
00:06:08.360 It was designed by the German architect Friedrich Tamms, considered by many to have set the foundation for a new architectural movement called Brutalism in the post-war era. We don’t want to maintain applications that are monolithic and brutal—authoritarian utilitarian codebases. We want to create small and elegant programs that can interact with each other in predictable and pleasing ways.
00:06:35.700 Both types of programs can be long-lived; ugly codebases are often too expensive to tear down, like that flak tower. Elegant codebases flourish, grow, and are extended over time, and if we’re lucky, we can choose the type of codebase we create and opt for something elegant.
00:07:09.650 Consider the open-source ecosystem: projects that are useful but difficult to work with won't attract as many contributors as more elegant and aesthetically pleasing codebases. This is a form of natural selection. Unlike closed-source software where we have to endure ugly code, in open-source, we get to choose the products we contribute to.
00:07:36.700 I mentioned natural selection intentionally because I believe that code is subject to natural forces just like organisms are. Elegance is an aesthetic experience; it’s about perfectly conforming to a set of imperfect standards. Elegance in code is a result of a mysterious process. I believe that elegance in nature arises from a similar mysterious process—and in nature, that process is evolution.
00:08:20.490 Let’s talk about some basics of evolution. We have genotypes, which are the genetic material defining the characteristics of an organism, like height, eye color, or fur patterns. Then we have phenotypes, which are the expressions of genetic information in physical characteristics. Natural selection is the process by which traits become more common or less common in a population as a side effect of their impact on reproduction.
00:08:49.930 A common example of natural selection occurred prior to the Industrial Revolution when forest moths were light-colored and blended in with tree trunks to protect themselves from predators. With the onset of the Industrial Revolution and the soot and contaminants in the air, tree trunks got darker, so the naturally occurring darker-colored moths had a survival advantage leading to a reproductive advantage. The forest moths we have today are darker than those from 200 years ago.
00:09:35.490 There's also artificial selection, where we deliberately breed for specific traits, as we do with food, dogs, and cats. But can aesthetics be a factor in evolution? In the U.S., we have a legendary figure called Johnny Appleseed. His name was John Chapman; he lived in the late 1700s and traveled far and wide, planting apple orchards from seed in areas he thought would be settled, hoping to sell the orchards to settlers.
00:10:03.640 He famously wore a shirt made of a coffee sack and always carried bushels of apple seeds. In the 1700s, sweets were a luxury; sugar was scarce until Southern plantations used slave labor to farm sugarcane. The only honeybees found in North America were those brought over from Europe, making honey rare. Fruit was the only source of sweetness available to most people back then.
00:10:38.630 Today, we think of apples looking like this, but every apple tree that produces fruit for eating is the result of grafting. Early colonists brought branches to graft onto native apple trees to generate edible fruit. If you take a Red Delicious apple, remove the seeds, plant them and take care of the tree, it won't produce a Red Delicious apple tree. Instead, you'd get a tree yielding inedible fruit, which is the kind of fruit that Chapman's orchards produced because he planted apples from seeds.
00:11:34.440 Was he foolish to plant orchards full of trees that yielded inedible fruit? No, because he wasn't interested in fruit for eating. His apples were perfect for making hard cider. The fermentation process made hard cider last longer than fresh apples and had the added benefit of being alcoholic. Thus, his so-called ugly orchards were quite valuable.
00:12:05.300 John Chapman was very shrewd until the 1830s when the temperance movement gained momentum, threatening the value of apple orchards. Apple growers began marketing the health benefits of fruit, which is where the phrase "an apple a day keeps the doctor away" originated. This was essentially marketing copy from the 1800s. Orchard owners began experimenting with new apple varieties, selectively cross-pollinating those that produced appealing, tasty fruit.
00:12:44.740 They were effectively boosting evolutionary forces to produce something that aligned with current aesthetics. The genetic expressions of apples have changed over the last 200 years, responding to the evolving aesthetic preferences of those consuming them. Precious branches were transported from Europe in the early days, but cider apples dominated until the mid-1800s. By the late 1800s, there were thousands of cultivated varieties, and now we’re left with about twenty.
00:13:29.940 Whether we guide their evolution through crossbreeding or inadvertently do so by selecting based on our aesthetic principles, we can have a direct effect on the evolution of things in our daily lives. Are our aesthetics an integral part of evolution, or are they merely an outside influence imposed by humans on the natural world? We can answer this question by asking: what do genes want?
00:14:17.070 You may have heard of the popular book, 'The Selfish Gene,' which was inspired by George Williams's book 'Adaptation and Natural Selection.' Its central tenet is that since evolution occurs through the survival of competing genes, natural selection and evolution are best understood from the perspective of genes rather than organisms or species. One interesting example of selfish genes is the green beard effect.
00:15:01.890 Imagine a gene that enables male species to grow a green beard while also inducing a tendency to be kind to other males with green beards. This can be thought of as a form of genetic self-identification. A gene in one individual offers a benefit to another individual with the same gene, but because two green-bearded males cannot reproduce, the genes act selfishly without regard for the fate of the organism.
00:15:48.160 The green beard effect manifests in technology as a tendency to stick with one programming language and the development of communities around that language. It is essential to understand that this phenomenon benefits the language more than it benefits us. We are not in charge of technology—it plays a different game.
00:16:36.720 Applying the notion of the Selfish Gene to programming languages, we can ask ourselves: what does code want? Code seeks ubiquity; technologies aspire to dominate their ecosystems, wanting to be everywhere—on your phone, your computer, your coffee maker. Ubiquity implies that technologies desire applicability to various problems.
00:17:20.050 Consider the development of APIs, which have evolved from RPC to SOAP, to XML, to JSON, and now GraphQL. The concept of an API remains consistent, but its expression, or phenotype, has changed to ensure the idea survives. Code desires longevity; it will do everything possible to live as long as it can.
00:18:05.870 Consider Unix, one of the most successful computer programs ever written. Its underlying philosophy emphasizes simple components and an openness to new protocols, giving Unix evolutionary advantages. How does code achieve what it desires? By being flexible. The flexibility of a given technology or language encourages specialization, reducing the cost of sticking with something familiar.
00:18:51.320 By being extensible, meaning the language can be used for novel applications, Ruby was initially designed as a system administration language, yet look at what it has become. By being novel, adding new language features, supporting new methodologies, and introducing new coding techniques, technologies find ways to keep up and engage us.
00:19:33.200 On the darker side, technologies achieve their ends through entrenchment. Consider the fallacy of sunk costs; if you’re a gambler on a losing streak who has lost thousands of dollars, you might think, 'This next hand will be a winner!' This mindset plays out in the tech realm when something becomes problematic to change, or when your code intertwines with every other system in your business.
00:20:36.430 Is it fair to compare natural selection and evolution in the natural world to programming concepts? If you think about it, programming languages serve as a genotype, providing access to allowable features and functionality. The expressions of a language's potential are like phenotypes; their environmental pressure pushes code to perform and compete in an interconnected environment.
00:20:59.040 There are physical and logical platforms, operating systems, infrastructures, protocols, and, of course, survival on the Internet at large. The competitive environment prompts us to consider natural selection, while artificial selection reflects deliberate intervention, akin to refactoring and maintenance.
00:21:01.940 The functional equivalent of a generation in programming is a version or cycle of attention. Artificial selection in evolving technology is guided evolution, following a roadmap to keep technology current and relevant. We have seen how external factors can affect genetic expressions in organisms; can the same apply to algorithms? How can we judge the aesthetics of a programming language?
00:21:55.590 I believe there are four main ways we interact with a language: writing source code, exploring documentation, reading source code, and interacting with the wrapper or command line. We must consider semantics, which include the syntax, keywords, methods, and the metaphoric design of the language. The command line refers to the ability to launch programs and interact with them via an executable environment like a console or IRB.
00:22:33.930 Documentation covers how well-documented language features are and how accessible the documentation is. Finally, readability is about how easy it is for a developer to understand how a program operates. I conducted a survey a couple of years ago across six languages and used five factors to evaluate their aesthetic appeal based on these four criteria.
00:23:04.620 I used that data to feed an algorithm called the Aesthetic Index. Python came out with the best aesthetic rating, followed by Ruby, JavaScript, C#, Java, and PHP. I thought it would be interesting to map these aesthetic ratings of languages against their popularity. There is a noticeable correlation between these aesthetic qualities of a language and how popular it is.
00:23:39.380 So that’s languages; what about the aesthetic qualities of code itself? The expression can be analyzed through four interconnected aesthetic principles. The first measure is correctness, which falls within the absolutist sphere of aesthetics. However, I don't believe correctness alone makes code elegant. I have to take a moment to address the views of Edsger Dijkstra, who believed that programming is an extension of applied mathematics and that elegance arises from correctness.
00:24:41.780 A couple of years ago, when I dabbled in AI again, I discovered a book titled 'Clever Algorithms: Nature-Inspired Programming Recipes.' It was filled with standardized algorithms derived from natural systems and written in Ruby. I was thrilled—it couldn’t have been more perfect. But when I opened the book, I found signatures of methods that were a staggering 15 arguments long and methods that went on for no fewer than 118 lines of code.
00:25:09.840 All the examples in the book were excessively procedural. It was written by a Ph.D. in Applied Science and a noted AI expert. From this, it was clear to me that elegance and correctness are not always correlated. The second aesthetic measure is performance, which I consider best understood through a hybrid perspective.
00:25:16.230 While performance can be measured precisely using benchmarks and tools, it is not about the benchmark value itself but rather the experience of performance that matters. If optimizing a query reduces the time it takes from 100 milliseconds to 50 milliseconds, your end users probably won’t care. But that same percentage improvement in page load speed could be greatly appreciated.
00:26:38.380 The third aesthetic measure is brevity, which can also be best understood through eclecticism. We instinctively recoil from bloated controllers or user models with thousands of lines of code and deeply nested conditionals. This invokes Blaise Pascal's remark: 'I wrote you a long letter because I didn’t have time to write you a short one.' However, brevity can negatively impact readability.
00:27:27.770 As readability is ultimately subjective, it’s important to remember that we primarily write code for humans first and for computers second. We must consider our particular audience. I would venture to say that unreadable code is as expensive as incorrect code. Tools like Rubocop help quantify and enforce aesthetic principles to keep methods short and favor lines of code that are less than 80 characters long.
00:28:11.760 I believe these four qualities combine in mysterious ways to create an aesthetic experience of code—what we call elegance. I once had a conversation with a friend about whether we can quantify elegance. If we apply my four measures to a grid, we can layout the four measures: correctness, performance, readability, and conciseness. Our aim should be to maximize the area of this graph, optimizing for balance and symmetry in these four dimensions.
00:29:01.410 The y-axis encompasses correctness and performance, which are utilitarian concerns, while the x-axis addresses conciseness and readability, which are more aesthetic concerns. For example, this piece of code is relatively balanced between correctness and performance but is less concise than it could be. This example sacrifices readability for conciseness; code that favors readability may be performance-incorrect. However, this is the goal we aspire to—achieving balance between all four aesthetic measures.
00:29:50.420 So why does this matter? Albert Einstein once wrote that after a certain level of developed technological skills is achieved, science and art coalesce, suggesting aesthetics play a role in greater scientific inquiry. As developers, we must ask ourselves: are we allowing ourselves to be artists? Are we granting ourselves the freedom to create elegant code?
00:30:28.090 We want to build cathedrals of code that are elegant and timeless. However, often our bosses push us to build quickly constructed, brutalist monstrosities that lack aesthetic appeal. We should reflect on why we write code: do we do it merely for financial gain or job security, or do we do it out of love for our craft?
00:31:05.510 Ultimately, writing code should be an opportunity to create something out of nothing, embracing the infinite potential of problem-solving. Who do we write code for? Interpreters? Compilers? Stakeholders? Users? Mostly, we write code for other developers, and we must account for their aesthetic sensibilities as well as our own.
00:31:47.650 We must be flexible and understand that elegance is subjective, yet we need to care about the experience others have when reading, debugging, or extending our code. Why do we care about quality? Is it simply a matter of maintainability and extensibility, or is it also that our names are attached to our commits?
00:32:27.270 We care about quality because the code we write is an extension of ourselves. We are not our code, but our code represents something intrinsic to our identity. Aesthetic appeal can be a key measure of quality—not necessarily only for stakeholders but importantly for the developers who genuinely own the code.
00:32:56.030 Architecture without aesthetics results in brutalism, and code lacking aesthetics is merely a commodity. Some may be comfortable being paid to write subpar code under insufficient conditions for a significant paycheck, but I refuse to be among them. Care about your code, recognize its needs, and foster a symbiotic relationship with it. Guide its evolution and allow yourselves to grow along the way.
00:33:41.340 Consider the experience of writing and reading code. We can decide what form our code takes. Code wants to be universal and ubiquitous; it is willing to be flexible, ensuring we remain engaged as it evolves. Whether we choose to engage blindly or actively, we have the power to create pleasurable experiences for both ourselves and others. Ultimately, it is our responsibility to tend to our code orchards to ensure the fruit of our labor is beautiful and delicious.
00:34:44.370 Thank you.
00:35:11.160 Thank you so much! Any questions?
00:35:28.690 Okay, yes. Thank you for this talk; it’s very inspiring. Do you have any way to—
00:35:31.610 Let me rephrase that: in your day-to-day programming life, you sometimes don’t feel the moment when you transition from building cathedrals to constructing thirty buildings. Do you have any tricks or methods to stay focused and ensure that you don’t slide into following only your boss’s directives?
00:36:57.240 I’ll be really clear: we are all under pressure to deliver code. We feel deadlines, but I believe we write better code when we take our time; we introduce fewer bugs that way. However, we have deadlines, right? My advice for you, if you feel pressure that prevents you from writing your best code, is to adopt a strategy that children learn to advocate for themselves at a young age.
00:37:23.980 Sometimes it helps to be a bit dishonest. For example, if you’re asked how long it will take to implement a feature, double your estimate. Lie about how long it will take. This approach will give you the time you need to craft your code beautifully, making it easier to maintain and better for other developers on your team.
00:37:51.530 So lie and slow down.
Explore all talks recorded at Paris.rb Conf 2018
+10