I inherited Eli’s code. He’d left for a start-up, and he’d written the import/export code for our application half done. He’d left in a hurry which meant I got a sixty-minute whiteboard session where he explained where he was at and where he was planning on going with his code. The whiteboard was pleasantly covered with method names and a lot of boxes and arrows and it seemed like an effective 60-minute meeting. When done, I felt confident I could finish the code.
Then I saw the code. His undocumented code. His spaghetti code.
It is a software engineering rite of passage to inherit and maintain a codebase that you did not write. If the original writer is a moderately good engineer operating against a well-defined engineering style and they have taken the time to document their code, it’s still an effort to parse and understand how a chunk of code works before you start to add your own.
Eli was not a good engineer, there was no style guide, and didn’t finish. But Eli did help me better appreciate Westworld.
Wait what?
DISCLAIMER: There are no season one Westworld spoilers in this piece, but you shouldn’t click on any links below. This piece does not assume you’ve seen the series, but it can’t hurt if you did. There is no code in this piece, either.
Westworld is an HBO series based on Michael Crichton’s 1973 movie of the same world. Like the movie, the series is about a futuristic Western-theme amusement park populated by “Hosts” who are lifelike androids. In this immense park, actual humans (“Guests”) show up for vacation, paying a huge amount of money to fulfill their no-holds-barred fantasy. This includes Guests nonchalantly gunning down the Hosts.
From the minds of Jonathan Nolan (Memento, The Dark Knight series, and Interstellar) and Lisa Joy (Burn Notice and Pushing Daisies), Westworld has complex depth. It is clear from the first episode that there are layers to the mysteries of Westworld. A torrential flood of theories appeared overnight after the first episode. With each subsequent episode, existing theories were refined while others were introduced. To date, I’ve spent three times as much time thinking and discussing Westworld versus watching it, and I’ve watched the series beginning to end twice. Perhaps a more compelling way to describe this act is I’ve been debugging Westworld.
There is a lot going on within Westworld. There’s what is going on in the park, there is what is going on with the administrators of the park, there’s a cast of characters who are androids who do not know what they are, there’s a cast of humans who treat the park like an amusement park, and there are those humans who believe the park is something else. Motivations are unclear, timelines are suspect, and so are narrators. Within a rich and complex set of narratives, there are constant reminders that there is more going on than meets the eye. Season 1 is written to be analyzed. It screams to be understood and to be debugged.
Attempting to debug Westworld is a similar act to understanding someone’s else undocumented code. The task begins by reading the code for the first time and beginning to build a mental model of how it works. The quality of the code greatly affects the difficulty of this task, and in the case of Eli’s code, this task was awful. Reading the code revealed no obvious model, and after a second read, I considered a complete rewrite. I didn’t have the time, and I also knew that all code obeys rules.
Eli’s code compiled, which meant it followed the basic rules. I could make basic guaranteed assumptions, so I began tinkering. What happens when I change this variable? Oh. What happens if this method is removed? Good to know. After many hours of deconstructing and reconstructing, I had a beginning model of how Eli’s code worked. It was still crap, but it was a bit more understood.
Here’s the process:
- Read the code, which is based on rules.
- Begin to build a mental model of how the code works.
- Test the model.
- Repeat until your model is sound.
In Westworld, the narrative is the code. It describes how that universe works, but as with any good narrative it wants to hold the viewer in suspense. The rules engine that drives this particular universe is meant to be discovered, and that is the joy of debugging Westworld – finding the rules.
Over the course of ten episodes, all the theories generated by the fans are an attempt to define the rule set of Westworld. What can the Hosts do? How much do they know? How far can they go to protect themselves? If Hosts look and act like the Guests, how do we know who is a Host or not? With each episode, new information presents itself, and theories are iterated and debugged.
At the end of the first season, it was reported that the Internet “outsmarted” the Westworld writers. The fact that many of the evolving theories about what was occurring in the Westworld universe were proven to be true was described as a sign that the show failed to live up to expectations.
This… is bullshit.
The fact that many of the popular theories were proven true indicates that Westworld is well designed. The narrative, the code, is proven to be structurally sound by the fact that viewers were able to infer the rules. A great majority of the viewers of Westworld were not obsessing over the apparently changing typeface on Dolores’s milk can. The majority of the viewers were casually consuming the show, but even by themselves they were building and debugging their rule set for the Westworld universe. They were perhaps more shocked by the twists at the end, but they were equally satisfied that twists made sense given their rule set.
A narrative whether it’s built with words or code must tell a complete story. The constitute parts must clearly contribute to a coherent and pleasant whole. Eli was a poor story teller, but Westworld’s story has just begun to be understood.
10 Responses