Home > Articles > Poetry for Software Engineers

Poetry for Software Engineers

Photo by Álvaro Serrano

I am not a poet. But when I was barely three years old, I was sitting at the kitchen table with my mother and older sister. They were working on rhyming words, because that is apparently the stage of childhood development my sister was in. My sister was struggling a little. My mom would ask her, "What's a word that rhymes with ball?" My sister replies, "bend." Mom says, "No, we're trying to make the end of the word sound the same. So a word that rhymes with ball would be fall. What are some words that rhyme with sky?" and my sister, with a confused look on her face, replies, "Soon? Sleep?". Mom says, "No, remember, we want the ends of the words to sound the same, not the beginning. So 'fly' or 'pie'. What are some words that rhyme with moon?" she asks. My sister says, "My?" and to hear my mom tell the story, my little voice pipes up, "Spoon! Loon! June!" which of course prompts my sister to give me an angry look and shout, "Shut up, Sam!"

I learned two things that day. First, it is immensely enjoyable to pick on one's older siblings. Second, I learned that words are interesting. They're fun. I like them. I like the way they sound when you say them and the power they give to express ideas.

In the time between that story and now, I've grown to enjoy poetry. This comes as a surprise to some who know me as a very analytically-minded person. And I get it–I mean, I'm a software engineer. Still, I've found a lot of joy in poetry. Beyond that, I think it's made me a better engineer.

Today we're going to talk about why I think you should read poetry. To do this, we're going to talk about how to read a poem, the ways that beauty is related to software, and a few things we can learn from poets.

So how do we read a poem? First, we need to be sure we're in the right mindset. In our culture, it's common for us to decide whether we like something immediately. For example, a friend of mine went to see the movie Wonder Woman, and I asked him whether it was a good movie. He replied, "Yeah, I liked it." But that's not exactly what I was asking; the quality of a piece of art or media is different from an individual's opinion about that piece. When we read poetry, it's important to understand what it's doing before we decide whether we like it or not. If you decide to read some poetry after this, I encourage you to read charitably. Try to understand what the author is saying and how she or he is saying it before you do anything else.

Once we're in the right mindset, we can dive into reading. For me, it's helpful to have a bit of a process to go through, and I imagine it can make this a little less weird if you are a so-called "left brain" person. I typically read through the poem three times:

Once I've done these three readings, I'm in a better spot to understand what the poet is saying. Let's do a practice run. This is a poem by Langston Hughes called "The Negro Speaks of Rivers".

I’ve known rivers:
I’ve known rivers ancient as the world and older than the
flow of human blood in human veins.

My soul has grown deep like the rivers.

I bathed in the Euphrates when dawns were young.
I built my hut near the Congo and it lulled me to sleep.
I looked upon the Nile and raised the pyramids above it.
I heard the singing of the Mississippi when Abe Lincoln
went down to New Orleans, and I’ve seen its muddy
bosom turn all golden in the sunset.

I’ve known rivers:
Ancient, dusky rivers.

My soul has grown deep like the rivers.

As I read through this, I circled the words "Euphrates" and "Congo"; I know they're rivers, but I'm not 100% on where they actually are or what they mean. I also circled "dusky", because I don't know the exact definition. Let me look these up.

OK, "dusky" means "somewhat dark in color; specifically : having dark skin". The Euphrates is a river in modern-day Iraq, and the Congo is in Africa.

Second reading. In the line "older than the flow of human blood in human veins", I put dots next to both occurrences of the word human. The word "bathed" in "bathed in the Euphrates" also sounded interesting, so I dotted that. I also dotted the word "golden" in "I've seen its muddy bosom turn all golden in the sunset".

Time for the third reading. On this pass, I underline "the Euphrates" as an allusion to the Biblical creation narrative. "The singing of the Mississippi" is an interesting image, as is "muddy bosom turn all golden in the sunset."

Now we're in a better place to understand what this all means. Langston Hughes lived in a deeply segregated America, and I find him making a powerful argument for a sense of common heritage and equality among all people. When he uses the word "I", he's referring to himself–a black man living in the Jim Crow society of the time. To say "I bathed in the Euphrates" is to paint a picture of the first man in the Bible as black. I imagine this was a shocking image to the society of the time, which had a "One Drop Rule" that meant if a person had even one drop of black blood in them, they were subject to the brutal segregation of Jim Crow. In this poem, Hughes shows that we are all human, thereby undermining the subjugating logic of Jim Crow.

I find this poem to be beautiful. Its construction is clearly well thought out, and the story it tells is a persuasive argument against segregation. But it may seem like we're on a bit of a rabbit trail here–how does any of this relate to software? Allow me to answer your question with a story.

Have you ever heard of "fizz buzz"? It's a well-known interview question in which you're supposed to print out the numbers 1 through 100, except when a number is divisible by 3 print "fizz", when it's divisible by 5 print "buzz", and if it's divisible by both print "fizz buzz". So the sequence goes 1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizz buzz, and so on.

The specific code to solve this problem could take a variety of shapes, but a straightforward Python implementation took around 9 lines. By contrast, there's a satirical GitHub repository called Fizz Buzz Enterprise Edition that consists of 1,387 lines of Java code spread across 89 files. Fizz Buzz Enterprise Edition is an exercise in using every design pattern you possibly can regardless of whether it actually improves the code.

I gave a presentation on the subject of poetry to some coworkers at one point, and I showed them the 9-line Python script followed by a single one of those 89 files in the Enterprise Edition. I asked them, "Which of these codebases is better?". The response was unanimous, of course: the Python script was better. When I asked them why they thought so, it took only a few seconds for someone to say the word "elegant."

And therein lies the answer to your question. When we start talking about what makes good code, the discussion quickly gets to the idea of "elegance", which I would say is a specific way of talking about beauty. In the software industry, we like to think of ourselves as innovators creating novel inventions, but when we start talking about beauty, we're incredibly late to the party. While some in this industry lambaste the humanities as useless, human beings have been trying to understand beauty for thousands of years. We would be foolish to throw away all we've learned.

Being a great engineer involves writing great software. And ideally, our software is elegant and beautiful. To get a sense for what those terms mean, we can turn to poetry. I've found that as I read more poetry and understand how it's constructed, I'm able to apply that knowledge to structuring my team's software. Understanding the way that a poet specifically chooses her or his words to fit the intention is fascinating and informs the way I choose to name functions, variables, and classes.

This takes us into our third point: we can learn a lot from poets. One day, the poet Ezra Pound was sitting in a subway station in Paris. As he looked around at the people walking through the station, he was overcome by a unique feeling. Like any good poet, he strived to capture that emotion in a poem. His first version was 30 lines. After six months, he'd carefully crafted and whittled it down to 15 lines. A year later, he published the poem In a Station of the Metro, which reads:

The apparition of these faces in the crowd;
Petals on a wet, black bough

Whether you like this poem or not, it's impressive in its ability to convey an image and an emotion by connecting two seemingly unrelated images. In the process of slowly and carefully carving away the excess and cruft from the poem, Pound is able to compress a lot of information into fourteen words.

We should strive to be more like poets. Good poets are able to express their ideas in precise language that communicates clearly. A huge part of the way they do this is by choosing their words carefully. This process is directly applicable to our work creating software. We're trying to encode some real-world process or use case into code that communicates our intentions to future maintainers. If we're sloppy with the way that we name things or structure our programs into functions, classes, or packages, the things we create will do a much worse job communicating the idea we have in our head to future maintainers.

Poetry is a useful hobby for software engineers. By helping us to better understand beauty and communication, poetry helps us develop skills that are directly applicable to creating good software.

I want to leave you with one last poem. Before I read this, I'm going to ask you to do something. I'm not trying to be manipulative, but I'm hoping to help you understand this author better. Take a few moments and think of someone who means a lot to you; it could be a family member or a close friend, but think about all the things that they mean to you and ways they improve your life.

The Gate, by Marie Howe

I had no idea that the gate I would step through
to finally enter this world

would be the space my brother's body made. He was
a little taller than me: a young man

but grown, himself by then,
done at twenty-eight, having folded every sheet,

rinsed every glass he would ever rinse under the cold
and running water.

This is what you have been waiting for, he used to say to me.
And I'd say, What?

And he'd say, This—holding up my cheese and mustard sandwich.
And I'd say, What?

And he'd say, This, sort of looking around.

Thanks for reading. I would love for you to tweet your favorite poem to me; I'm @SamuelDataT. Now get out there and read some poetry!