“All of the food materials today and 4,000 years ago are the same: a piece of meat is basically a piece of meat. From a physics point of view, the process is the same. There is a science there that is the same today as it was 4,000 years ago.”
— Patricia Jurado Gonzalez, quoted in Winchester (2019)
Every few years, there is another an article describing the ongoing work of historians trying to re-create older recipes. Depending on the sources and site, this could be deciphering cuneiform (Winchester, 2019), working from ancient clay tablets (Eng, 2020), or discussing the popularity of cookbooks in early America (Veit, 2017). In nearly every case, an observation makes it way into the article: while the technology is slightly different from the past, the ingredients are identical. The processing might be faster, but the input and output are the same. As Patricia Jurado Gonzalez notes, “there is a science there that is the same today as it was 4,000 years ago.” (Winchester, 2019).

One of the most influential books on programming starts with a quote from a cookbook. In the Preface to The Art of Computer Programming, Knuth (1968) quotes from McCall’s Cookbook (1963),
“Here is your book, the one your thousands of letters have asked us to publish. It has take us years to do, checking and rechecking countless recipes to bring you only the best, only the interesting, only the perfect. Now we can say, without a shadow of a doubt, that every single one of them, if you follow the directions to the letter, will work for you exactly as well as it did for us, even if you have never cooked before.”
— McCall’s Cookbook (1963)
On the very first page of The Art of Computer Programming, Knuth (1968) states that “The notion of an algorithm is basic to all computer programming, so we should begin with a careful analysis of this concept” (p. 1; original emphasis). A few pages later, Knuth (1968) defines the formal elements of an algorithm: (1) finiteness, (2) definiteness, (3) input, (4) output, and (5) effectiveness. After defining each term in relation to an algorithm, Knuth (1968) returns to the theme introduced in the Preface, writing “Let us try to compare the concept of an algorithm with that of a cookbook recipe” and precedes to compare an algorithm and the elements of cooking, noting the importance of definiteness and finiteness in cooking. Knuth (1968) then writes that “The author has in fact barely resisted the temptation to name the present volume ‘The Programmer’s Cookbook’ because of the similarities between the two actions (p. 6).
In drawing the connection between algorithms, a term unknown to most audiences in 1968 and cooking, something done for thousands of years, Knuth (1968) builds what Lakoff and Johnson (2003) call a structural metaphor. In connecting algorithms to recipes, Knuth (1968) creates a relationship between the familiar (recipe) with the unfamiliar (algorithms), bridging the concepts as consisting of the same general patterns of having a collection of steps, needing input and producing output, and being able to compare one to another on how effective they produce their outcomes. An algorithm is not the same as a recipe, of course, but they share in coherence and in how their elements relate to the greater conceptualization of the whole.
The use of the word “structure” in the conception of structural metaphor by Lakoff and Johnson (2003) is important. It highlights the use of the metaphor as something which can be build upon and added to by other concepts. The comparison of two things, write Lakoff and Johnson (2003), “[gives] coherent structure to a range of our experiences” and “creates similarities of a new kind (p. 151; original emphasis). The “structure” of the metaphor, through being a bridge, invites comparisons in both directions. The reflexive quality of the metaphor shines light both ways. In comparing two things, they become linked and can be understand as relating in coherence from either side of the comparison. Knuth (1968) might be comparing algorithms to recipes, but the reverse is also true: recipes are like algorithms.
In reflecting on the history of cookbooks in early America and how they connect to their modern counterparts, Veit (2017) makes an observation:
“Designed as a teaching tool for a mobile society, the modern recipe is grounded in principles of clarity, precision, and replicability that emerge clearly from the conditions of early American life. They are principles that continue to guide and empower cooks in America and around the world today.” (Emphasis added)
Put in a different context, Veit (2017) could also be writing about algorithms. If they are clear, precise, and able to be reproduced, the algorithm could become popular. Yet, implicit to Veit’s (2017) principles and missing from the explicit listing of the formal elements of algorithms by Knuth (1968) is an insight gleamed from the metaphor introduced by Knuth (1968): replicability. A cookbook lists processes to be followed, but their explicit output is not another recipe. An algorithm, on the other hand, is written to be re-written. It must be “removed” from the book into another medium to be run.
When Knuth (1968) jokes about the renaming of The Art of Computer Programming to “The Programmer’s Cookbook,” Knuth (1968) draws attention to a comparison built on the metaphor at play between recipe and algorithm. When a user follows a recipe, they produce a materiality that is fundamentally different than the outcome of following an algorithm. That is, before an algorithm can be used, it must be re-written from the book itself. It must be translated out of the “book” into source code, be that by typing out the “recipe” or by copying and pasting it from a more digital source. The first step in following the process of using an algorithm, then, is in reproducing the text itself in such a matter that it can be run by a computer. This makes it a text for a human for a computer, a layer hidden in the nature of the “book” itself.
In writing about critical code studies, Marino (2020) comments on the role of metaphor in writing about how it is conceptualized: “unless that metaphor has significance with respect to the particular, material context of the script itself, the interpretation will seem more of an imposition, a projection” (p. 53). In the now 50+ years since The Art of Computer Programming (1958) was published, what does the staying power of the “material context” of the use of recipes and algorithms say about how they are both used? Lost to the metaphor of a “Programmer’s Cookbook”, perhaps, is the pedagogical role of recipes: they teach people processes through doing.
In creating a printed book of examples, Knuth (1968) invokes the pedagogical nature of algorithms without naming it as such. In order to be used from the book, someone would need to write them into code, thus being trained in their style and syntax. Just as this translation shifts the “particular” of the implementation, it also serves as a training to both programmer and computer. A user must learn the algorithm to teach it to a computer. For a recipe, this translation does not happen. Yet, to even understand this comparison, the metaphor must have already been established.
As Veit (2017) noted, recipes have become more finite and definitive over time. They have become, through cooking technology, more effective, taking less time to prepare input for processing. Yet, as Patricia Jurado Gonzalez observed, the science is the same. The recipes of old and those of more current times still produce an editable outcome. Across the bridge of metaphor, recipe and algorithm might have more to offer each other in comparison than appears at first glance. Both, in their ways, encode steps for others to follow to achieve some end. They each teach their users in different ways, marking knowledge through the materiality involved in their transformations.
While Knuth (1968) was not the first to note the comparison of algorithms and recipes, the popularity of The Art of Computer Programming cemented the metaphor of a comparison algorithms and recipes. Its placement within the Preface and echoed again in the first few pages of the book mark it as an important theme in understanding how code should be written through the lens of the steps followed to prepare food — something that has been taught for 50+ years. While it might have been meant as a joke of sorts at the time, the metaphor has remained a structure for many others through its inclusion and usage in the teaching and technical resources following in the footsteps of The Art of Computer Programming since its publication. “Computer recipes” are here to stay in the structural metaphors built into the lexicon of programming and understanding technology starting with, as Knuth (1968) described it, “[a notion] basic to all computer programming”: the algorithm.
References
Eng, J. (2020). Cook Like an Ancient Mesopotamian With the World’s Oldest Recipes. Atlas Obscura. Retrieved from https://www.atlasobscura.com/articles/mesopotamian-recipes
Knuth, D. E. (1997). The art of computer programming (3rd ed). Addison-Wesley. (Originally published in 1968)
Lakoff, G., & Johnson, M. (2003). Metaphors we live by. University of Chicago Press.
Marino, M. C. (2020). Critical code studies: Initial methods. The MIT Press.
Veit, Z. H. (2017). The Making of the Modern American Recipe. Smithsonian Magazine. Retrieved from https://www.smithsonianmag.com/history/making-modern-american-recipe-180964940/
Winchester, A. (2019). The world’s oldest recipes decoded. BBC Travel. Retrieved from http://www.bbc.com/travel/story/20191103-the-worlds-oldest-known-recipes-decoded