To Your Left Is Coding, to Your Right Is Safety: Programming Stories

October 24, 2018 | 1 book mentioned 7 min read

1.
The logic of novice programming goes something like this:

Run function (x, y)

If x is greater than y:

Do this

Else if y is greater than x:

Do that

Else:

Something else happens.

I quickly learned that computers don’t like choice, and they don’t like the unexpected. If you fail to anticipate every scenario or condition—say, that x and y might be the same number—it will shout at you and stop working. If you tell the computer that x is A and y is 6 it will shout at you and stop working. As a bad novice programmer, I know this from experience. Treat the computer like someone you don’t trust to turn off the lights and lock the door without careful instructions. Be that micromanager who tells his employee what font to use and how to stack the coffee cups. Forget all you’ve heard about AI and machine learning and algorithms. Novice programming is a bit like running army drills. First do this, then that. Then loop back and do it again.

I have a humanities brain, or at least it’s trained that way. I told myself I was a bad programmer because I was trained in the logic of fiction. I could easily understand that Jane Eyre could seduce Rochester because, contrary to appearances, the meek governess was strange and strong-willed and had a psychedelic imagination. And I could accept that she finally married him because the power relations between them had shifted, or he was metaphorically unmanned, or because Charlotte Brontë could not resist a touch of Victorian sentiment. The marriage was not simply a logical consequence of the death of the first Mrs. Rochester. First this, then that.

coverOf course, there are novels that behave differently. Tristram Shandy explodes all illusions of psychological realism and narrative closure. It turns itself inside out and makes explicit all the possibilities that are open to the writer. But I spent my teenage years reading Victorian novels that were heavy with fate and determinism. Even where protagonists appeared in control of their destiny, the presence of an omniscient narrator whispered that we were in good hands. Choice, agency, and free will were illusions. But Laurence Sterne will have none of it. His story lurches backward and forward, forever mixing up causes and consequences. He demands interactivity; here is a blank page for the reader to draw his own impression of the sex-obsessed Widow Wadman: “as like your mistress as you can—as unlike your wife as conscience would let you.” Tristram Shandy irked me. It was not for a lazy reader.

coverBy the time I found Flann O’Brien’s At Swim-Two-Birds I’d loosened up a bit. “Every story should have a beginning, a middle and an end” says one of its windy Dubliners. “I like to know where I am, do you know.” But the novel flouts every one of the rules of fiction. There is no “this, then that” in At Swim: “A good book may have three openings entirely dissimilar and inter-related only in the prescience of the author, or for that matter one hundred times as many endings.” The novel begins with a story within a story within a story, but the nested narratives spill into each other. Disorder is its organizing principle. Yet the real oddities of At Swim turn on the question of choice. Characters rebel because they don’t like the roles assigned to them, so they take over the writing of the novel. At Swim-Two-Birds may one day read like a fable about the triumph of AI over its creators.

Still, a reading life can be a bad preparation for the logic of code. That is, unless you go back to the beginning. A fairy tale might be read as a collection of functional elements populated by variables. There are stories that open with banishment: A younger son is sent away to find his fortune; Hansel and Gretel are left in the forest; a new stepmother drives a girl away from home. And then there are magical interventions: A fairy godmother appears to Cinderella; an enchanted fox instructs a hero how to capture a golden bird; a horse warns his huntsman against picking up the feather of the firebird. In a fairy tale, there is no psychological depth or complex chain of cause and effect to complicate matters. Event quickly follows event.

coverAnd there are few surprises. If the glass slipper is lost, the prince will find it. Good behavior will be rewarded and bad behavior will be punished. Whatever the storyteller’s skill (or lack of it), the ugly stepsisters will hobble themselves and Rumpelstiltskin will be defeated. The taxonomy of the fairy tale is closer in spirit to the narrative logic of the computer program than it is to the sprawling complexities of modern novels. Vladimir Propp’s Morphology of the Folktale has been adopted by legions of game designers for good reason. If you can classify all the narrative functions—the building blocks—of Russian tales, and if you can reduce all those princes and witches and holy fools to just seven character types, maybe you can imagine the conditional branches and loops that can handle their permutations.

A confession, though: Reading fairy tales has not made me any better at writing code.

2.
So I turned to Twine. Created by Chris Klimas in 2009, Twine is “an open-source tool for telling interactive, non-linear stories.” In other words, it is an open platform descended from Choose Your Own Adventure stories and text-based parser games like Zork—the kind of games where choosing to turn left instead of right can mean a quick death at the hands of an unfriendly ogre. You don’t need to understand code to write and publish a Twine story. But you do need to think in terms of conditional logic. Easy. I would use interactive fiction to trick myself into learning how to think like a programmer. That was a bad idea. My Twine stories soon had all the molten spaghetti structure of my Python code.

Better Twine writers get control of those loops and conditions. They play around with the reader’s freedom to change the story, or rather, with the reader’s illusion of choice. If interactive writers can create dozens of paths through inventive and intricate worlds, they can also exploit the reader’s entrapment in them. Repetitive gameplay can seem like purgatory, but how else can you explore an interactive story only by going back to the start and playing again? The best storytellers make the most of these conditions, understanding game mechanics just as well as they do narrative structure. And the very best Twine stories engage with the peculiarities of the form—not least that the protagonist is often the reader or player herself.

A case in point is howling dogs by Porpentine, a California-based new media artist and one of the most celebrated writers of Twine fiction. Howling dogs opens with you, the reader, in a cell, “a room of dark metal. Fluorescent lights embedded in the ceiling.” You have access to food and water, a toilet, a shower, and a garbage chute; you have access to a “sanity room” with calming pictures, and a photograph of a woman you once loved. A counter reads 367 (days? weeks?). Your only escape is to put on a virtual reality visor that brings you to vivid and strange worlds. But each journey ends with you back in your cell, the counter climbing and your surroundings growing more filthy and neglected. You can put on the visor again, but first you must eat and drink—repetitively going through the same pathways to access water or unwrap a nutrient bar. Howling dogs is a bleak parable: Each time you escape, reality returns. You must eat and drink and wash, do the bare minimum to keep yourself alive, and each time you leave the virtual world your situation seems more grim and more hopeless.

You can stay in the cell, but nothing will happen. You can strap on the visor—peering through a slit at a beautiful garden or finding yourself in the middle of a bloody battlefield. You might be a woman about to be executed, like Joan of Arc, or an empress with a bone foot who is destined to be sacrificed. But in exercising your choices, you become complicit in the designer’s plan. A woman is deciding whether to kill her lover: “Would you help me kill him? Yes. No.” Choosing “no” offers no escape: “Very well. But you must watch.” Similarly, you can refuse to take part in the horrors of battle, but if you do, you will find yourself sipping tea with a socialite as others die. The actions you take only exacerbate your sense of powerlessness.

And that is one of the most interesting conjunctions of code and story. A programmer and a storyteller delimit possibilities. They model scenarios. A good writer of interactive fiction has the programmer’s skill for breaking down a problem or a scene into its smallest parts. From those tiny elements come branching stories. But the choices they offer are necessarily limited, which has implications for the kinds of tales you can tell. Depression Quest by Zoe Quinn, Patrick Lindsey, and Isaac Schankler cleverly exploits this aspect of interactive fiction to dramatize the experience of depression. As the protagonist you have many choices in the early part of the story: You can talk to a friend, go out to a party, take a shower. But as depression grips more strongly, these options begin to appear on screen crossed out. You are put in the situation of someone for whom it is becoming harder and harder to act.

So choice can be an illusion, and it is no accident that many Twine stories play on a sense of entrapment. Kevin Snow’s Domovoi gives that feature a metafictional slant. A visually lush staging of a Russian folktale, Domovoi is narrated by a folklorist who invites you to advise how the story should unfold. But the storyteller is not always happy with your choices. As the folktale progresses a testy conflict can break out between the narrator and the reader. What emerges is a cautionary tale—one inspired by the Russian folklorists of the 1930s who twisted traditional tales into the service of Soviet ideology. Domovoi is a story about the politics of telling stories, and with its folktale trappings it is also a reminder that interactive storytellers have been around for a very long time.

3.
Twine taught me one thing: Some of the problems of code are the problems of writing. Often it can feel like there are too many possibilities. It is only when you have already started to write your story or design your code—wrongly or clumsily, perhaps—that you can draw the way ahead into focus. And then you see it is the wrong way, and you start again.

I still cannot write code. But I like the fact that Agile software development is predicated on stories, of a kind—the user stories that predict how code might work in the real world, the problems that it’s there to solve. I know I’m no developer; I can’t imagine all scenarios and anticipate all consequences. I cannot model everything that will happen if I begin writing in one way and not another. But I like to imagine, at least, that thinking about code is also thinking about stories: about a labyrinth of possibilities, a Scheherazadean abundance of tales. But that might just be my humanities brain talking.

Image: Homestar Runner, Thy Dungeonman 3 screenshot

's essays have appeared in The Dublin Review, Headstuff and The Dublin Review of Books. She has published a book on Flann O'Brien and was an Irish Research Council Post-Doctoral Fellow in Trinity College Dublin. Read more at www.caroltaaffe.com.