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.
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.