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

Image of Geek Sublime: Writing Fiction, Coding Software
Author: Vikram Chandra
Publisher: Faber and Faber (2012)
Binding: Paperback, pages
Image of Alif the Unseen
Author: G. Willow Wilson
Price: $11.47
Publisher: Grove Press (2013)
Binding: Paperback, 448 pages
Leah Dearborn

Column by Leah Dearborn

Leah Dearborn is a bibliophile and bookseller from the frigid North Shore of Massachusetts. A graduate of the journalism program at UMass Amherst, she spends her spare time blogging about books (of course), history, politics, and events in the Boston area. Occasionally, she spits out something resembling fiction, and has previously served as a contributor to Steampunk Magazine. She collects typewriters and old novels and laments the fact that her personal library has outgrown her apartment.

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 - 7: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 - 8:03am


Elizabeth Dearborn's picture
Elizabeth Dearborn from Florida is reading The Monuments Men April 14, 2016 - 1: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!