Columns > Published on April 12th, 2016

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:
   mything.stuff() 

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

About the author

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.

Similar Columns

Explore other columns from across the blog.

Book Brawl: Geek Love vs. Water for Elephants

In Book Brawl, two books that are somehow related will get in the ring and fight it out for the coveted honor of being declared literary champion. Two books enter. One book leaves. This month,...

The 10 Best Sci-Fi Books That Should Be Box Office Blockbusters

It seems as if Hollywood is entirely bereft of fresh material. Next year, three different live-action Snow White films will be released in the States. Disney is still terrorizing audiences with t...

Books Without Borders: Life after Liquidation

Though many true book enthusiasts, particularly in the Northwest where locally owned retailers are more common than paperback novels with Fabio on the cover, would never have set foot in a mega-c...

From Silk Purses to Sows’ Ears

Photo via Freeimages.com Moviegoers whose taste in cinema consists entirely of keeping up with the Joneses, or if they’re confident in their ignorance, being the Joneses - the middlebrow, the ...

Cliche, the Literary Default

Original Photo by Gerhard Lipold As writers, we’re constantly told to avoid the cliché. MFA programs in particular indoctrinate an almost Pavlovian shock response against it; workshops in...

A Recap Of... The Wicked Universe

Out of Oz marks Gregory Maguire’s fourth and final book in the series beginning with his brilliant, beloved Wicked. Maguire’s Wicked universe is richly complex, politically contentious, and fille...

Learning | Free Lesson — LitReactor | 2024-05

Try Reedsy's novel writing masterclass — 100% free

Sign up for a free video lesson and learn how to make readers care about your main character.