Shall I Compare Thee to a Line of Code? – Lauren Scott

Lauren is trained as a creative writer, but, surprise, poetry does not pay the bills. By her estimates, the best selling poetry book in the US made 44.000 dollars, and the second one… 4000.

Lauren found programming to be similar to poetry, with the exception that people do pay you for it. This talk will be a super quick rundown of poetry and a comparison to code. The basic building blocks are:


There are two important categories:

Form poems, like limerick, haiku which may or may not have a rhyme scheme and
Free verse, anything goes!

Lauren promises us that poetry is not boring, but she does not blame us for thinking so, as poetry taught in schools can be very stuffy.


So how does poetry compare to programming?

Of course, nummer 1: Language

Both programming and poetry involve manipulating words and using syntax.

As Oscar Wilde said: “I have spent most of the day to put in a comma, and the rest of the day to take it out”

That sounds familiar if you are programmer, right!

2: White space

As a developer, one of the first things you learn is formatting your code: using indentation to convey meaning. And it is not just meaning, it is also that visually, they look similar:


Without being able to read the poem, you get a feel from the poem. It feels organized and elegant. If you compare that to an E.E. Cummings poem, it feels so different:


In both programming and poetry, you strive for brevity, but you want to convey as much information as possible. You try and use the constraints you have and make the most of it. Like with form poetry. Let’s look at sonnets (Elizabethian sonnets not Petrachan), which work like this:

  • 14 lines long
  • Three quatrains (4-line stanzas)
  • The volta (a logical turn, not physically present in the poem)
  • One couplet (2-lin stanza)
  • All in iambic pentameter

There is a rhyme scheme too: ABAB, CDCD, EFEF, GG

Let’s read some Shakespeare! Sharespeare’s Sonnet no. 130

This clearly has a volta, while first enumerating all the ways his lover is not perfect, in then end, he turns it around. While sticking to the described from. (what Lauren did not address, but is even more impressive, is translating this (Dutch version here))

So why do these forms exist?

One of the reasons is to help memory, in the age of Shakespeare, written language was rare, and a clear form helped to remember. But it is also a way to get you started, to help you think about sound. The forms are there to help!

And, challenges are fun! When Lauren started writing poetry, writing sonnets was like a puzzle: how to get the message into this form? Even if it is not the right format perse. There are, obviously, many forms in programming too: frameworks, languages, design patterns etc. And sometimes, you are fighting against the form you have chosen, or you have to ask yourself: if your form the right form?

Not every poem is a sonnet.
Not every app is MVC.

But what makes code/poems good?

Lauren wanted us to see this gif, but it failed in her slides, so here:

In both fields, people love conciseness: so just use enough to make yourself clear. There is a tradeoff here between fact and beauty, what you want to convey versus how it looks like. An example that strikes the right balance, according to Lauren:

A nice thing to notice here is that there are references, I believe Lauren said something like he is drawing on the collective experience of people. You know how a petal looks like, and he references that. It is like importing and using a library.

But you can go too far in removing things. What is the poem was: “I saw faces in the crowd. They were beautiful.” That does not have the same meaning! The same things can happen to code. Sometimes you make your methods so small that you make code less readable.

Or, you go the other way:


Not as nice, right? Poetry also has the DRY principle: you say it once, and you say it well.


Of course where the balance lies is very dependent on context. How do you know what is right? Let’s look into how creative writing is taught. Can we learn something from that for programming education? The education works with ‘workshops’ where you give your work to your classmates (you are ‘workshopped’) and they give you feedback. And you are not allowed to jump in, you cannot defend yourself or jump in. Even if they get is totally wrong, and misinterpret what it is about. While this might sounds horrendous, this is a gift, as it shows you what your poems says, when your are not there.

The metaphor for code is so rife!

Lauren argues that you should try this in code too, try    being     silent.

In the context of code, this might mean:

  • Implement workshop-style code reviews
  • Stay silent in code reviews or on PRs until you’ve gotten feedback (but let your colleagues know you are doing this)
  • Weekly lunch & learn, workshop style
  • Start a Coder’s Workshop with friends
  • Just embrace silence personally

A few fun links to read more:


This post was visited 246 times.