Lauren Scott

Shall I Compare Thee to a Line of Code

Ever wish that your peers called your code a "work of art"? What is it that artful programmers know that makes their work transcend functionality and become something that has value in its essence? There's a lot that we can learn from the arts, particularly from those that share our linguistic building blocks. Because as all programmers and poets know, writing is easy—it’s writing the good stuff that’s hard.

So what can we take from the study of poetry that would illuminate our own paths as developers? In this talk, I’ll go through some poetic principles that clarify ideas about software development, both in the way we write our code and the way we grow as creators and teammates. We’ll explore the way poets learn to shape their craft and see what we can steal to help our code level up from functioning to poetic.

Ancient City Ruby 2016

00:00:00.000 All right, hi everybody! I'm excited to be here with you all today. My name is Lauren Scott. You can find me on the Internet as Dev Dame pretty much everywhere.
00:00:05.879 I'm from Chicago, Illinois, and I’m a developer at Braintree and one of the chapter leads for RailsBridge. I'm also a poet. So, if any of you here are poetry nerds, I'm reading "Fern Hill" by Dylan Thomas.
00:00:18.449 That'll probably mean nothing to you, but if it does mean something, it's like, yeah. I have about eight years of formal education in poetry; I got my BA in Creative Writing with a focus on poetry. After that, I worked retail, because surprisingly, being a poet isn’t a career that I considered for a while.
00:00:38.190 So I had to find something else to do, and programming was a really good step for me. It's a field that suits people who are both logical and creative, and unlike poetry, people actually pay you for writing code, which is a definite plus.
00:01:03.270 Before we get started, show of hands, who here likes poetry? That was a really good showing; I'm excited about that! For the rest of you in the room, or those who just like art but aren’t into poems, let's do a quick rundown.
00:01:14.369 We're going to clarify some of the language and terms we’ll be using today. First, we have 'the poem.' This is actually called 'The Poem' by George Oppen, a poetry of the meaning of words and a bond with the universe. He says, "I think there is no light in the world but the world, and I think there is light."
00:01:30.900 So obviously, we have the poem. Let's break it down, though. Then we have 'the line'—the line is similar to what a sentence is in prose. The line is poetry. Then, there’s a place where we choose to make the line break; you can think of it as your <br> tag. Then we have stanzas, which are like the little nuggets of poem lines that you see with white space between them.
00:02:21.170 Now, let’s talk about one more important distinction: form poems and free verse. This will come up a lot today. You might know form poetry; think of sonnets, limericks, and haikus. These are poems that have a set structure or pattern and might have different constraints such as rhyme and meter.
00:02:46.370 On the other hand, free verse is anything that isn’t form poetry. Free verse has no constraints; no rhymes are required. Most poetry that people write today is free verse. It’s not that free verse ignores rhyme and meter; it just doesn’t have a predetermined structure.
00:03:10.630 Poetry isn’t as stuffy as you think. I know a lot of people believe that poetry is antiquated or not useful, but it doesn’t have to be the case. There’s a type of poetry I call 'Bluebird poetry,' which talks about fanciful things. And you don’t have to like Bluebird poetry in order to enjoy poetry.
00:03:22.670 To kick things off, I’m going to read a short poem by Dennis Johnson called "Heat." It’s fairly modern, from the 1970s.
00:04:01.010 "Here in the electric dusk, your naked lover tips the glass high and the ice cubes fall against your teeth. It's beautiful Susan, her hair sticky with gin. Our Lady of wet glass rings on the album cover, street coming with hatred in the heat as the record falls, and the snake band chords begin to break like terrible news from the Rolling Stones. In such a last light, full of spheres and zones, August, you're just an erotic hallucination, just so much feverishly produced kazoo music. Are you serious? This large oven impersonating night, this exhaustion mutilated to resemble passion. The bogus moon of tenderness and magic you hold out to each prisoner like a cup of light." So, no bluebirds right?
00:04:54.150 If you still think that poetry is stuffy, there is definitely poetry out there that is a lot harder than what I just shared. And it's not exactly something that's tech-presentation friendly. So we've talked a bit about poetry; let's start getting into the things it shares in common with programming.
00:05:24.690 You might have already noticed the biggest and most obvious connection: language. Both poetry and programming create meaning from language. Language is the creative medium at our disposal, and when I say 'creative,' I don't necessarily mean that your code will be as creative as a poem. I mean that we are creating something new with our medium. But with language comes syntax.
00:06:06.390 This is a great Oscar Wilde quote: “I've spent most of the day putting in a comma and the rest of the day taking it out.” Doesn’t that sound familiar? In poetry, like in programming, a single piece of punctuation can completely alter the meaning of a line.
00:06:23.940 So, there has to be huge attention to detail. You've got to make sure that everything is exactly right at the moment it’s created—like the Oxford comma, for example. The Oxford comma is the comma put before 'and' in a list of three things. People think of it as optional, but I think it’s pretty important.
00:06:47.530 Let’s look at an example with and without the Oxford comma: "We invited the rhinoceros, Washington, and Lincoln" versus "We invited the rhinoceros, Washington and Lincoln." It could really change everything! This example concerns grammatical rules, but in poetry, you don’t always have to be grammatically correct. However, the way you use syntax and the way you put your words together really matters.
00:07:13.889 Every decision impacts the reader’s impression of the poem. If you don’t want the poem's voice to sound formal or authoritative, you might choose not to use capital letters or all punctuation. Conversely, if you want to evoke a sense of anxiety in the poem, you might use a lot of run-on sentences or do line breaks in unexpected places.
00:07:40.570 Then we have white space, which is the negative space that surrounds your words. This can have a huge effect on poetry, too. The same words with different white space can convey different meanings to the reader. As a programmer, one of the first things you learn is how to format your code properly because otherwise, nobody will understand what you’re trying to communicate.
00:08:17.169 And in some cases, white space is the key to the computer understanding your instructions. In both fields, you must develop a gut response to how things look. We all know the feeling of looking at Ruby code and intuitively knowing it’s poorly structured just from the white space alone.
00:08:43.780 If you need convincing that white space is important, think about it this way: consider a humidified HTML. None of us will understand that mess; it’s chaos. The white space allows us to read the code and comprehend it.
00:09:11.840 One of the first similarities I noticed when I started learning to program was how often code and poetry visually mirror each other. For example, I have some source code from Rails contrasted with a Sylvia Plath poem. I blurred them out, so we’re not focused solely on Sylvia Plath—she always steals the show.
00:09:31.200 But you can see how the stanzas in that Plath poem look a lot like the methods in Rails, right? Just like those methods, the stanzas are separated by white space to delineate thoughts.
00:09:56.220 Now, if we look at this E.E. Cummings poem, you can tell just from the white space that the feel will be different than the previous one. Different spacing conveys different moods and feelings. In both forms, you have something you want to communicate to the reader through language.
00:10:27.480 A poem has an expected output much like a program does. It aims to convey an emotion or an idea or deliver a feeling to the reader. You can think of it as a program where the reader enters the poem, and we want the poem to change them by the time they exit. It’s like a destructive method.
00:10:58.020 Both poetry and code strive for brevity. You try to convey as much as possible using the least amount of words. This represents yet another example of the constraints we face. Poetry and coding are both about creativity within those constraints.
00:11:30.570 As I mentioned earlier, an important form of constraint in poetry is the choice to use form poetry. Let’s dig deeper into that by examining sonnets. For those interested, we're talking about Elizabethan sonnets today, not Petrarchan sonnets. There’s a big difference!
00:12:05.690 First things first: sonnets are 14 lines long, composed of three quatrains, which are stanzas of four lines each. In a sonnet, there’s a logical turn called the Volta, which occurs at the end of the three quatrains.
00:12:30.890 The argument is built throughout these quatrains, leading to that pivotal moment of twist, followed by two concluding rhymed lines called couplets. All of this is typically expressed in iambic pentameter, which consists of five pairs of alternating unstressed and stressed syllables.
00:12:51.560 One of the best-known examples of this is Shakespeare’s works. A classic opening line is "But soft, what light through yonder window breaks?" We also have rhyme schemes, which can vary; you can see I laid it out with the end words of a sonnet about to be shown.
00:13:12.880 So, you can see the ABAB pattern where the A’s rhyme with each other and the B’s rhyme with each other. We have a lot to unpack from this structure. Let’s take a look at a specific sonnet by Shakespeare.
00:13:46.850 Pay attention to the logical progression and the Volta: "My mistress' eyes are nothing like the sun. Coral is far more red than her lips' red. If snow be white, why then her breasts are dun? If hairs be wires, black wires grow on her head. I've seen roses damask'd, red and white, but no such roses see I in her cheeks. And in some perfumes is there more delight than in the breath that from my mistress reeks. I love to hear her speak, yet well I know that music hath a far more pleasing sound. I grant I never saw a goddess go; my mistress when she walks treads on the ground, and yet, by heaven, I think my love as rare as any she belied with false compare."
00:14:14.320 You can see how this form works for Shakespeare. In the first three stanzas, he builds an argument demonstrating how imperfect his mistress is. It’s somewhat of a harsh critique as he compares her to idealized beauty. Yet he draws the conclusion that because he doesn't idolize her, his love becomes genuine.
00:14:58.140 A lot goes into crafting this sonnet; so much effort is needed to compress your thoughts into this form. If you think this is hard, just remember there are more complex forms, like the heroic crown of sonnets—one poem made up of 14 sonnets in a row, culminating in one more sonnet constructed from the first lines of all those sonnets.
00:15:31.420 Forms originated in poetry for specific reasons, particularly for memory aids in a time when oral traditions were key to literary knowledge. These structures help people grasp, remember, and feel the poetry.
00:16:06.750 Furthermore, forms provide guidelines that help organize thoughts, pay attention to sound, and develop patterns or rhythms. Ultimately, one crucial thing they help you do is simply to get started, as determining how to begin a creative endeavor can often be challenging.
00:16:37.480 Each form brings its unique set of tools to the table, allowing numerous creative opportunities. Challenges can be fun! I know this is an overused meme, but it perfectly captures how I felt when I first encountered sonnets.
00:17:03.750 I committed to writing everything in sonnet form, even to the point of using it for my college entrance essays—all in iambic pentameter in quatrains, with end rhymes! It was completely unnecessary, but I enjoyed the process, regardless of whether the logical progression was there.
00:17:43.340 It’s easy to zero in on low-level challenges, trying to make your thoughts fit that meter or rhyme scheme because it’s fun or frustrating. But amidst this focus on structure, don't neglect to consider the higher-level challenges, like whether you should be using that particular form and if it helps communicate your wider ideas.
00:18:18.889 This echoes some of our tools in programming: frameworks, languages, design patterns like MVC. We struggle at times against the constraints imposed by our chosen frameworks. While it's okay to bend rules, pay attention to when you may be pushing back against fundamental structures that provide benefits.
00:19:05.890 What good is it doing? Would a different form be more beneficial? Trust yourself to make changes, but recognize the red flags when you've deviated too far or are resisting the inherent value of the structure in use.
00:19:36.270 Now what? You’ve got your form, free verse, whatever you pick—pick a language, pick a framework, and start writing. But then we come to another question: what really makes code and poetry good?
00:20:00.830 To answer this, we must recognize that both are subjective fields. There’s no universal rule for writing the best code; opinions will vary widely—even in this room, you all will likely have different approaches to solving similar problems.
00:20:38.710 What's difficult is teaching something that shifts so much based on context. We can’t simply offer one rule to ensure the best outcome every time; it requires looking at the context. However, many guidelines exist to help us.
00:21:01.500 One key guideline is to say a lot with a little. Use just enough language to convey clarity. In both fields, people appreciate conciseness, so ensuring each word serves a purpose matters.
00:21:42.150 One question I often ask while writing poetry is, "What has this word added?" I evaluate what I would lose if I removed it. Determining what’s necessary is a critical consideration.
00:22:18.750 So, how do we define necessity? Today, I’ll explore it in terms of two factors: fact and beauty. By ‘fact,’ I mean the functionality or message of the code—what the code does or what the poetry means.
00:22:47.300 Then there's beauty—clarity in the code, readability, or the evocative imagery in the poem. We all assume that readable code is something essential we strive for. This is how 'you say' works.
00:23:10.950 Let’s look at a famous poem for saying a lot with a little: "In a Station of the Metro" by Ezra Pound. It reads: "The apparition of these faces in the crowd; petals on a wet, black bough." Here, Pound effectively conveys a surplus of emotion in just two lines.
00:23:43.510 This is a poem beloved by literary enthusiasts, with many having it tattooed. Now, you might wonder why this works so well. Without beauty, the fact can become irrelevant. A poem that straightforwardly explains its meaning might lose its intrinsic magic. Likewise, convoluted code could function but is unreadable, causing your colleagues to struggle.
00:24:17.610 If Pound had stripped the essence too far, he might’ve ended up with something mundane: "I was in the metro. I saw faces in the crowd. They were beautiful." Not only does this feel lackluster, it loses depth and richness.
00:24:57.170 In order to breathe life into your code or poetry, balance is paramount. However, too much elaboration can dilute your message. If you overemphasize imagery, it can distract the reader just like excessive comments can detract from effective code.
00:25:32.590 Had Pound gone overboard with his elaboration, we could have faced prose that reads like: "I was deep in the Metro, observing the crowd, and the faces appeared as if they were ghosts. The Metro was a gloomier cavern, but the faces represented delicate glimpses of beauty." Not quite impactful, is it?
00:26:07.830 Poetry also follows the rule of not repeating oneself. You want to express ideas clearly without redundancy. This brings value to your code, too; by using effective methods and variables already shared, you can conserve energy and deliver clarity.
00:26:43.400 Ultimately, remember the human aspect. If you work with other developers, recognize that your code is not only meant for machines; it’s also consumed by people. Forgetting readability can cut individuals out of the equation.
00:27:14.860 Your output is akin to journaling rather than poetry. Ask yourself, are each of your words necessary? Is there something that hasn't been said? The goal remains that readability can be just as vital as function.
00:27:42.320 Now that we’ve discussed the challenges in writing, we need to address another topic: teaching. How do we effectively communicate context, particularly since many of these guidelines rely on gut instincts?
00:28:15.600 Workshops form the backbone of poetry education. When writing poetry, you often participate in workshops—these little classes with a small number of people, maybe eight, where peers provide feedback.
00:28:55.060 When it's your turn to be workshopped, you send your poems off with your classmates. They read it, markup, and critique your poem. Everyone then reconvenes, and you read your work aloud to the class.
00:29:28.640 This can be quite terrifying! You must sit in silence for much of the discussion, which can be hard when your classmates critique your work. They may misunderstand your intentions and debate meanings you never intended.
00:30:02.520 This silence ultimately grants you the gift of allowing your poem to speak for itself. You won’t always be available to defend it when it emerges in literary publications. So, it’s vital to reflect how people react to your work without your input.
00:30:38.600 In programming, bumps arise whether you return to the code after a break or try debugging a year later. Often, you won’t remember the decisions you made, causing confusion. This highlights the importance of your code’s ability to articulate for itself.
00:31:09.420 This practice of listening and revising leads to my last point: Revision circuits. It’s common to feel attached to what we create, considering our work precious. However, this notion can hinder us as creatives.
00:31:42.770 When you pour a lot of yourself into something, it’s easy to see it as perfect. But our work’s preciousness can stagnate our growth. We’re often inclined to treat our poems or code like children—refusing to let them change.
00:32:08.590 Accepting your work as valuable yet not integral to your identity is vital. Revise and readjust to grow; remember, the majority of well-known poems undergo extensive revisions. Early drafts often appear nothing like their final forms.
00:32:48.090 If these poets had kept their work sacred, they might never have achieved their current masterpieces. It’s important to keep in mind that sometimes, like a prairie fire, things must burn down before they can flourish anew.
00:33:15.529 Thank you all for listening to me.
00:32:47.659 Do we have any questions? No? Okay. Just in case you didn’t have any, I have one more thing I wanted to share.
00:32:53.940 There’s a wonderful book called 'Code Poems.' It’s a project started by programmers back in 2012 who recognized the similarities between these two realms.
00:33:10.290 They brought together several programmers, artists, and poets to write poems that are also valid, compilable code. This book is only available at the Contemporary Culture Center in Barcelona, but you can buy it from their website.
00:33:29.510 I made a nerdy pilgrimage to that place to get the book, and while reading one of the poems, 'For Agnes,' I was blown away—it moved me to tears.
00:33:49.170 The poem goes: "For you, Agnes, in which time do find, if you can, there is nothing Agnes to be done until you know, do you know who am I? Look my Agnes, if you only could, then I’d rejoice, patch false hopes from nothing to nothing. Done. Done: less 0 SE V, Agnes.” So, that’s what I wanted to share. Thank you all!