Finding Poetry In Computer Code

In his 1984 book, Literate Programming, computer scientist Donald Knuth wrote, “The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and the excellence of style. Such an author, with thesaurus in hand, chooses the names of variables carefully and explains what each variable means.”

Computer science and literature don't often walk firmly hand-in-hand. Looking at a string of code against a solid black terminal, it seems improbable that it could serve any function aside from the most practical one—telling a machine what to do. But Knuth believed that logic and language could merge to create higher-quality programs. Maybe it's possible to flip the equation and create higher-quality writing using the logic of programming.

There's no way around it; it seems that machines are still machines built by human minds.

A few years ago, I picked up G. Willow Wilson's novel, Alif the Unseen, and was fascinated by the overlap between the fantasy world she builds and the bits of programming interwoven with the plot. Magical incantations include Linux commands, and theological questions are discussed alongside quantum computing. Interested in exploring more along this avenue of experimentation, I came across code poetry and the code poetry slams held by Stanford University.

Because my knowledge of computer languages is rudimentary, I sat down with my partner, an experienced systems engineer, and asked his opinion on the code poetry and the possibilities of combining programming and human language.

“That's beautiful,” he muttered, reading over “Baby Steps Towards Sentience” by Aimee Norton, which includes a lullaby in Fortran.

I waited until he was finished and asked, “Is it possible express to emotion in code?”

“No, because it's a command-driven language. Programmers don't have words like 'love' because we don't need to express them, the same way that not all human languages have direct translations for all words. If a culture has no use for a thing, there's no need to name it.”

So what exactly is “code poetry,” then? Even Stanford admits that the definition is hazy:

For a start, it can mean poems, written in a programming language, that are meant to be read purely as words on a page...code that aims for elegant expression within severe constraints, like a haiku or a sonnet...or code that generates automatic poetry...Some definitions are directly at odds with each other.

After wading through more code poetry, I came across The Shakespeare Programming Language, which evolved out of a class on lexical and syntactical analysis. The designers state their main goal as to “make a language with beautiful source code that resembled Shakespeare plays.”

“That makes much more sense,” my partner added, taking a look for himself. “When you're writing a script, it's called a script for a reason. It's literally a script like a story script. Think of Tybalt as an object, and you're saying 'object exit stage left.' You're giving commands to each character as an object. It's more like scriptwriting for a play than communicating a thought directly to a human. You're telling them what to say, how to act and behave. Think of each object as an actor, or a prop.”

Is there a linguistic elegance to code? Is it only ever for issuing commands, or can it be for the enjoyment of the programmer? Certainly, a well-written piece of code is as pleasing to its creator as a perfectly placed metaphor is to a writer. Beyond that, however, programming may be able to impart some lessons on language structure. For instance, these two commands mean the same thing:

Example 1
mything = do()
If value == 0:

Example 2
mything.stuff() if value == 0 else None

Basically, 'do' is a class and 'stuff' is a function in the class. You have the function called 'stuff' within the class of 'do.' If value is 0, do 'stuff.' The computer will do 'stuff' under the execution of either example—it's a human preference for a more aesthetically pleasing, easily readable piece of code that might drive someone to write it out using the second methodology. There's no way around it; it seems that machines are still machines built by human minds. 

Image by Yuri Samoilov

Leah Dearborn

Column by Leah Dearborn

Leah Dearborn is a Boston-based writer with a bachelor’s degree in journalism and a master’s degree in international relations from UMass Boston. She started writing for LitReactor in 2013 while paying her way through journalism school and hopping between bookstore jobs (R.I.P. Borders). In the years since, she’s written articles about everything from colonial poisoning plots to city council plans for using owls as pest control. If it’s a little strange, she’s probably interested.

To leave a comment Login with Facebook or create a free account.


CS's picture
CS from Biloxi, MS is reading Zen in the Art of Writing: Essays on Creativity April 13, 2016 - 8:08am

Nothing quite says "I love you" like:

01001001 00100000 01101100 01101111 01110110 01100101 00100000 01111001 01101111 01110101

LeahD's picture
LeahD from Boston is reading The Devil In The White City April 13, 2016 - 9:03am


Elizabeth Dearborn's picture
Elizabeth Dearborn from Florida is reading The Monuments Men April 14, 2016 - 2:32pm

Yes, the great Donald Knuth created the computer typesetting language TeX, pronounced "tech". He wrote it with mathematicians in mind, but it is used for many other projects:

I notice we have the same last name!


JeremyTickell's picture
JeremyTickell August 31, 2020 - 10:19am

Haha...this is hilarious. Finding poetry in computer code is an amazing and astonishing thing. Thanks for sharing this with us. Also you need to write my essay to get quality content for your task. This is a very interesting blog page. Innovative things like this will prevail in the future. Keep sharing more.

Johnelia's picture
Johnelia February 18, 2021 - 5:48am

Yes, the great Donald Knuth created the computer typesetting language TeX, pronounced "tech". He wrote it with mathematicians in mind, but it is used for many other projects:

I am totally agree with it

JacquesMorgantau's picture
JacquesMorgantau April 20, 2022 - 6:36am

I see for the first time such a creative approach towards code writing. Never thought one could think of it as a poetry, while the concept of The Shakespeare Programming Language fascinates me most. To be frank, I can't code the way I want  hence I do my coding homework relying on Assignment Core service solely. Hope some day I'll manage to do code tasks better and even become a true professional able to see the beauty in code the way Shakespeare did in language.