èƵ

Rhyme and reason: Writing poems in computer code

Beyoncé's tweets as sacred text, error messages that tell a tragic tale and the looping program of a failing relationship: we parse a new literary phenomenon
Rhyme and reason: Writing poems in computer code

Beyoncé’s tweets as sacred text, error messages that tell a tragic tale and the looping program of a failing relationship: we parse a new literary phenomenon

ON STAGE at Stanford University in California last February, the words of Beyoncé were being intoned as a religious text. Next came Richard Branson. Then Elon Musk.

This was the second Stanford Code Poetry Slam: a celebration of code poetry, a reimagining of computer programming languages as a form of literary expression. The winner, Hunter Bacot, had written a short, elegant program called 21st Century Prophecies that pulled in the latest tweets from a selection of famous names to be read out as if they were sacred commandments. The crowd went wild.

“It’s really interesting to see language in a new way,” says , who organises the Stanford slams. “People have been writing in English for so many years. This is a whole new medium and a whole new set of possible metaphors.” The results are always unusual, often complex and occasionally moving.

The definition of code poetry is rather broad. In its purest sense a code poem is a piece of code that runs as a program but also works, on some level, as poetry. These create some of the most effective and dramatic poems.

But the slam also accepts entries that use what Kagen calls “coding idiom” to create a distinct poetic effect. For example, one of this year’s finalists, Apache Code Errors, used a list of error messages from Apache server software – which runs much of the web – to tell the story of how Native Americans in the US lost their land. Another, Capsized by Zachary Kain, was written in CSS, a language used to style web pages, to describe a boating accident. “It was lovely and so short. Ambiguous and quiet,” says Kagen.

The Stanford slams add a new element – poetry as performance. Often a code poet will climb on stage and recite the poem as they type it out on a laptop, with the live coding projected on the wall. “Poetry is beautiful on the page, but you also get something out of it out loud that you don’t just from reading it,” says Kagen. “We wanted to explore the mouthfeel of a code poem.”

The concept of code as verse won’t be new to many programmers: good poetry and well-written code have much in common. Both contain densely packed information that is nested within something that has been elegantly written. No lines are wasted.

Although it helps if the reader has a certain familiarity with the coding language being used, non-coders can still enjoy trying to grasp hidden meanings. Nevertheless, in-jokes for coders abound, like the use of a looping program to depict the repetitive arguments of a failing relationship in Sandra Trinh’s If Nothing Else.

It has even caught the eye of a few mainstream poets. “I love the way punctuation becomes more than a guide for making sense of the language,” says UK poet Amy Key. “It is almost ornamental.”

For Ben Allen, also at Stanford and a co-organiser of the most recent slam in November, code poetry is interesting not just for any literary merit it might have, but also for what it tells us about coding languages themselves. “It’s a way of exploring the boundaries of this distinct mode of expression that’s become so important to our lives,” he says, “to continue the debates from early computing about how language-like code could be, or should be.”

What do mainstream poets think of code poetry?

, whose first poetry collection Luxe was published in 2013, thinks code poems are fascinating.

I’m interested in a disintegration of the boundaries of genre, and in this context I find code poetry very intriguing. I love the way punctuation becomes more than a guide for making sense of the language. It is almost ornamental – the snazzy accessories on a plain black dress, drawing the eye, creating variation.

was less convinced. Riviere, whose 81 Austerities won the Forward Prize for Best First Collection in 2011, says that although the code poems appear innovative, they are actually fairly conventional in content – and that’s a big problem.

We have unremarkable, paraphrasable content presented in the form of a self-announced “different” language. I would be more interested in the inverse, I guess – whereby the techniques and processes of coding languages are somehow brought to bear on the composition of poetry.

It’s as if with code poetry the transposition is happening the less interesting way around. “Using” code to make poetry with quite conventional intentions, rather than imagining the sort of poetry that might be more revealing about the uses and consequences of programming languages.

, whose first collection The Claims Office came out in 2013, describes himself as a mainstream “page poet” – his poems are meant to be read, not performed. What he liked about code poetry was that it existed outside the cliquey, factional nature of contemporary poetry that he normally comes across.

What these guys are doing is so far removed from the poetry I would generally read and enjoy that all those battle lines recede, and it becomes possible to have an innocent encounter with something genuinely weird and unusual.

I’ve enjoyed that encounter more or less, but it’s a lukewarm, cerebral sort of enjoyment, with no sense of excitement or danger that a poem could come in and upend my entire emotional world, as all of my favourite poems have done at some point.

Here are a handful of our favourite code poems. Check out Stanford University’s for more.

Capsized

by Zachary Kain

.ocean {
color: cornflowerblue;
pitch: high;
overflow: visible;
}

.boat {
color: firebrick;
transform: rotate(94deg);
float: none;
}

.rescue-team {
visibility: visible;
}

.crew {
widows: none;
}

Dai George says: Capsized by Zachary Kain is clever, and I see the narrative running through the found language of CSS. I don’t know enough about CSS to comment on how the poetic intelligence behind the poem is interacting with this other type of language; presumably there are rules and conventions that are being honoured and/or transgressed. My two major stumbling blocks are, a) how to read the curly braces, which are so far removed from ordinary language that I understand they pretty much only occur in computer coding, and b) well, if Kain wanted to write about an accident at sea, why didn’t he just do so, without CSS? What does the constraint bring to the table?

The answer to that is probably that code poetry only exists within a constraint, so if that isn’t your bag, then nor is code poetry. The frisson and the pleasure comes from rescuing meaning from meaninglessness, or at least radically different fields of meaning. But I’ve been asked to comment on it from the point of view of a mainstream poet, who has no such circumscribed field of meaning, so it can’t help but feel like a fairly severe and limiting handicap. A fun game, but fun for anyone else?

Me and You

by Matthew Lee

import random

traits = [“only speak when spoken to”, “never know how to introduce myself”, “hide in the middle of a group”, “lead in the front”, “make my opinions known”, “do all of my homework”, “have a plan”, “know what will work and won’t”, “believe in true love”, “get caught in the past”, “know the future will be better”, “want to please”, “set goals”, “smile at strangers”, “watch my feet when walking”, “look for things to do”, “let things unfold”, “climb trees”, “keep my feet on the ground”, “walk fast”, “drive slow”, “read the newspaper”, “watch cartoons”, “eat breakfast”, “believe in the midnight snack”, “snore”, “yawn loudly”, “love vegetables”, “eat gluten-free”, “get cold easily”, “need a hug”, “get lost in eyes”, “hate my reflection”, “sing in the shower”, “give others the benefit of the doubt”, “double-check the lock on the door”, “watch the sunrise”, “floss”, “hide my scars”, “listen to Chopin”, “keep a diary”, “scrapbook”, “knit”, “sweat a lot”, “wash your hands before eating”, “pray”]

def Me():
               my_trait = traits[random.randint(0, len(traits)-1)]
               print “I ” + my_trait + “.”
               return my_trait

def You():
               your_trait = traits[random.randint(0, len(traits)-1)]
               your_trait = your_trait.replace(“my”, “your”)
               your_trait = your_trait.replace(“am”, “are”)
               print “You ” + your_trait + “.”
               return your_trait

def WillItWork(me, you):
               print “Will it work?”
               willitwork = random.choice([“Yes”, “No”])
               print willitwork + “.”
               if willitwork == “No”:
                    print “Will it be okay?”
                    print random.choice([“Yes”, “No”]) + “.”

me = Me()
you = You()

WillItWork(me, you)

I look for things to do.
You hate your reflection.
Will it work?
No.
Will it be ok?
Yes.

Dai George says: I actually enjoy Matthew Lee’s poem, or should I say “poem generator”, quite a lot. It has a quizzical, dissociative train of thought that wouldn’t appear out of place in certain fashionable literary journals right now.

I dare say that the random, generative aspect plays well with a view of literature influenced by literary theorist Roland Barthes, his essay The Death of the Author, and the – a literary school whose texts often have random, reader-generated aspects, and which antedates personal computers by a good couple of decades. That isn’t my bag, but it’s much more of a recognisable bag than the CSS poem, and at heart it’s not a uniquely technological approach to literature.

When I look more closely at the range of Lee’s input data, though, I can’t help but remark on a failure of poetic imagination: if he wanted it to have more legs as a model for generating great, or even mediocre, poetry, he might have used his human brain to come up with more inspiring options than “want to please” and “read the newspaper”. The arbitrariness surely can’t be an end in itself – you have to load the tombola with decent material in the first place.

A slim volume of code poems

Here are a few more code poems to puzzle over and – hopefully – enjoy. All were performed at Stanford code poetry slams.

21st Century Prophecies by Hunter Bacot – the winner of the second Code Poetry Slam at Stanford University – pulls in the latest tweets by a variety of famous names. When performed, the tweets are intoned as if they were a religious text.

21st Century Prophecies

by Hunter Bacot       

the_medium = “twitter”
require the_medium
medium = Twitter::REST::Client.new do |medium|
     medium.consumer_key = ” “
     medium.consumer_secret = ” “
     medium.access_token = ” “
     medium.access_token_secret = ” “
end

virtues = []
virtues << medium.user("elonmusk").tweet.text
virtues << medium.user("KingJames").tweet.text
virtues << medium.user("Pontifex").tweet.text
virtues << medium.user("KimJongNumberUn").tweet.text
virtues << medium.user("Beyonce").tweet.text
virtues << medium.user("richardbranson").tweet.text
virtues << medium.user("god").tweet.text
# a moment of clarity
virtues <<"\n#{Faraday.get("https://api.github.com/zen").body}"
File.open(“prophets_manifesto.txt”, “w”) do |out|
     virtues.each { |truth| out.puts truth }
end

system “open prophets_manifesto.txt”

Sandra Trinh’s If Nothing Else is like an in-joke for programmers. The looping program replays the repetitious arguments of a relationship.

If Nothing Else

by Sandra Trinh

Private Conversation
          Declare I As “melodramatic heroine”
          Declare You As “almost villain”
          Declare Setting As “our shared bed”

          If I = a few glasses of whiskey in
               You = disgruntled person

                You.Argument(myDrinking)
               Grievances = 3

                Loop If Grievances >= 0
                    You.Output(“I love you, but”)
                    I.Output(“Just say it”)
۴dz.ܳٱܳ(Ұ𱹲Գ)
                    I.Output(“That’s bullshit ” + why do I keep
                    trying + “we’ve talked about this already ” +
                    I keep doing this over and over again + “I
                    thought we were over this ” + I can’t do this
Բ⳾ǰ)

                    Grievances = Grievances – 1
               End Loop

               If I = still have energy to fight
                    Us.Argument(anything, everything)
                    You = unwilling to be with me
                    I.beginPacking(books, clothes, whiskey)
                    You = say you still love me
                    I = drink some more

                    I = sleep on the floor
                    where Carpet = soft + comfortable +
                    more hospitable than CurrentSetting

               You = sleep in a few minutes
               I = curl up against a hard corner
.󲹳ܲٱ(ٱԻ徱Բ)
.ٰ԰(𲹱³󾱲)
End

Apache Code Errors by Aimee Norton uses a list of error messages from Apache server software – which runs much of the web – to tell the story of how Native Americans in the US lost their land.

Apache Code Errors

by Aimee Norton

201 created
200 OK
100 continue
200 OK

303 see other
302 found
303 see other
409 conflict

403 forbidden
520 origin error
402 payment required
413 too large

303 see other
405 not allowed
417 expectation failed
423 locked down

502 bad gateway
307 redirect
204 no content
205 reset

305 use proxy
422 unprocessable entity
426 upgrade required
409 conflict

415 unsupported
429 too many requests
416 not satisfiable
417 failed

306 switched proxy
444 no response
449 retry
511 authenticate

301 moved permanently
401 unauthorized
506 variant negotiates
523 declined

406 not acceptable
451 illegal

599 timeout (unknown)
424 failed dependency

496 no certificate
423 locked away
598 timeout
598 timeout

Topics: Books and art / Festive science