Once Upon an Algorithm: How Stories Explain Computing
(The MIT Press)
US: Aug 2017
“The idea for Once Upon an Algorithm arose from many conversations with friends, students, colleagues, and people I talk to on the bus on my way to work. I thank all of them for their patience in listening to my explanations about computer science and for their friendly impatience when the explanations became too long and complicated.”
—Martin Erwig, Once Upon an Algorithm, Acknowledgements
Once Upon an Algorithm is at points an enjoyable, engaging read, but despite Erwig’s apparent assertion that this book is for anyone wanting to learn about what “computer science” actually means, it’s hard to figure out who the audience for this book is.
Here’s the conceit of Erwig’s book: the idea of computer science, and some of its most fundamental constructs, are explained in a way that relates them to familiar stories. By explaining the concept of an algorithm by likening it to the famous tale of Hansel and Gretel, or explaining how a loop works by likening it to Harold Ramis and Bill Murray’s Groundhog Day, Erwig seeks to establish an understanding of programming that a mere programming manual or textbook cannot hope to match. It is, after all, one thing to say “I want to learn to code”; it’s another thing entirely to open up a book or do a Google search and not instantly become too overwhelmed to continue.
This sort of understanding is a fine goal, and his choice of pop culture texts to apply to computing’s basic tenets is spot-on every time, both in terms of general public familiarity with the stories presented and in terms of how he applies those stories to code. While it’s true that not everyone is going to know every story, Erwig ensures that even if you don’t know the story, you get the basic idea of the part of that story that applies to the idea that he’s talking about. For example, the first story that Erwig uses is Hansel and Gretel, which is his basis for teaching us about the very idea of an algorithm. Erwig wisely leaves the majority of the plot out of his discussion, focusing instead on the trail of breadcrumbs that Hansel leaves so that the pair may find their way back. Rather than bring the house they find, or the witch, or the reason their breadcrumbs didn’t work into the discussion, Erwig’s focus on the breadcrumbs allows him to focus on the definition of an algorithm.
In this case, of course, the “algorithm” is not comprised of the breadcrumbs themselves, but the thought processes that went into dropping them and the processes involved in following them back home. This distinction is important because it is that level of abstraction that allows us to apply those same principles to computer code. Erwig’s clarity in this point is necessary and well-expressed.
The problems seep in with Erwig’s choice of language. He’s a professor at Oregon State, and for better or worse, he writes like a professor.
In one of the book’s final chapters, Erwig is using Harry Potter to introduce us to the basics of Object Oriented programming. He introduces a segment on typing rules like this:
In addition to supporting the efficient derivation of information about particular objects, types enable reasoning about the interaction of objects and thus provide a way to make predictions about the world. This can be achieved through a set of rules, called typing rules, that describe whether and how objects of different types can interact.
At heart, there’s nothing wrong with Erwig’s writing here. It makes its point, it’s clear, it’s straightforward. It’s also dry and academic. The appeal in the idea of a book like Once Upon an Algorithm lies in the potential to make programming accessible, to make it feel less like a series of magical incantations known only by a select cadre of the mathematically minded, and more like something anyone could do. Erwig is a professor writing like a professor. While there may be a context in which that works, it’s a style of writing that plays against the potential accessibility of the subject matter. It’s definitely too heady for young readers, who might otherwise find some appeal in likening programming to familiar stories and films. It’s likely too dry for many adults, who might be hoping for some personality to go with the appealing conceit. Sadly, the ideas are likely too basic for an academic looking for a deeper understanding of programming.
The only real potential destination that makes sense is an intro-to-programming class for first-year students. Placed alongside a more explicitly code-oriented programming textbook, Once Upon an Algorithm makes sense as a document of “why” when consumed with a document of “how”. If this is a textbook, the student to whom it is assigned will have classwork-related reasons to push through the language and gain the understanding that Erwig is trying to pass along. Otherwise, it’s difficult to see a reader sticking with it, despite the admittedly clever analogies on display.
"Osmon lights the oil lamps on the process of Molina’s creative wonder, from toddling on the shores of Lake Erie to the indie folk pedestal he so deservedly sits upon today.READ the article