Cooking as Coding

If it is not already obvious, one of my favorite hobbies is cooking. Recently, as I was toiling away on a seafood risotto, I had a realization: cooking is a form of coding. People might enjoy cooking for many of the same reasons people enjoy coding. If you think about it, the similarities between these two activities are striking:

  • Fundamentally Creative. When you cook, you are engaged in a fundamentally creative task. You are using your hands and your skills to build something. This is no different than when you sit down to code; you are the master of your food (or program’s) destiny.
  • Scientific Basis. Cooking is not a realm of mysterious alchemy. It is based upon rigorous principles of chemistry and physics. To create a delicious meal, you need to obey those scientific principles. When you write code, you similarly ought to understand the computer science and mathematics that underlies your work.
  • Real-Time Debugging. Coders love to constantly test and debug in real-time. They like to quickly write a function, test it out, and revise it as needed. The same is true in cooking. Debugging consists of sticking your spoon in and having a taste. Then you adjust your ingredients or technique as necessary.
  • Open-Source Documentation. Within both cooking and coding, there is a beautiful culture of sharing knowledge. Cookbooks, of course, are a form of open documentation. More importantly, ask most anyone for a recipe of something they’ve made, and they oblige. Both cooks and hackers take a pride in their creations and love to share their code/recipes.
  • Black-Box Abstraction. Meals can be modularized into constituent parts. For example, a pie consists of a crust and filling. To make a pie more easily, you can use an off-the-shelf crust, even if you don’t know how it was made. This black-box abstraction resonates well with a programmer’s instinct to reduce complexity through modularization.
  • Instant Gratification. This might be the most important attribute. In many fields of engineering, you have to wait a long time to see the results of your work (e.g., building a bridge). The fact that coders can quickly play with their creations is what attracted many of them to computer science in the first place. Cooks get to enjoy this exact same kind of instant gratification. A chef’s code is edible!

Given the vibrant similarities between cooking and coding, I would love to see software engineers have a stronger influence on the discipline of cooking. Beyond the gizmos of molecular gastronomy, here are a few more cultural ways engineers could improve cuisine:

  • More science-based culinary training. With the exception of Harold McGee’s On Food and Cooking, very few (cook)books teach much about the science of food. As a result, very few people really understand the science behind cooking. This inhibits their creativity in the kitchen. Instead, it’d be wonderful to see more cooking texts that teach science– from the physiology of taste, to the chemistry of ingredients, to the thermodynamics of heat transfer.
  • More innovative recipe templates. The canonical recipe template (e.g., opening notes, ingredient list, prep instructions) is out of date. There is a lot of room to innovate on how we articulate recipes. There are, for example, better ways of visualizing parallel activities, or incorporating video demonstrations of standard techniques. Recipes need to come into the 21st century.
  • More knowledge of reverse-engineering. Whenever coders come across a new piece of technology, they try to figure out how it works. They are masters of reverse-engineering. People are often the same way when they enjoy new dishes at restaurants. By learning a more rigorous methodology for reverse-engineering meals, people could greatly enhance their cooking technique.

Can you think of other ways the culture of computer science can enhance the culinary world? Given that software engineers revel in both the artistic and technical demands of the creative process, I think that geeks are bound to make fantastic contributions to the culinary arts.

5 Responses to “Cooking as Coding”


  1. 1 Matthew W March 15, 2010 at 8:04 PM

    As a developer and a cook I couldn’t agree more.

    I would also like to see more flexible recipes which reveal a bit more about the structure of the cooking that’s being done:

    * Explain why certain ingredients techniques are used
    * Explain which ingredients or techniques are critical to the recipe and which are less critical
    * Where an ingredient is only used as an arbitrary choice from some class of suitable ingredients, explain this
    * Explain how the recipe varies when certain parameters (eg cooking time, temperature, ratios of certain ingredients) are tweaked, that is, describe the neighbourhood of your recipe in n-dimensional phase space :)

  2. 2 novalis March 15, 2010 at 8:12 PM

    Hi. I’m another programmer-cook, and I agree that there is some slight overlap in skills.

    There are actually books other than McGee’s that offer scientific information. Here are two on confections and bread, both of which I own and learned a lot from.

    There’s also the more formula-based approach of Ruhlman.

  3. 3 Paul Grayson March 16, 2010 at 5:21 AM

    As someone who has done ruby, C#, and Bechamel today, I couldn’t disagree more! The two disciplines are only about as related as any two creative activities. Coding is fundamentally objective and unforgiving, while cooking is fundamentally subjective and forgiving. Leave out a single semicolon and your program does not compile; forget to reset a variable and people can die. There are few recipes that produce dangerous results if the ingredients are added in the wrong order, and doubling or quadrupling the quantities of various ingredients is purely a matter of taste. A subtle reordering of steps in cooking will never let you produce exactly the same dish a thousand times faster; but that is typical of coding.

    You say cooking is based the science of chemistry, and this is vaguely true, though pretty much no cooks know it, there is very little knowledge brought in from science into the kitchen, and chemical reactions or interactions between multiple ingredients are rare. Let’s say I like cooking bread and know pretty much nothing of the science. Can you name a single scientific fact that will greatly improve my bread?

    Coding, on the other hand, is almost totally separated from the physical world – it is much closer to mathematics than to science. Show me one place where knowledge obtained with the scientific method has an influence on computer programming! Try imagining an alternate universe where salt is not used in cooking – that’s easy! Now try imagining an alternate universe where loops are not used in programming – that’s very, very hard!

    There are far too many people who think that coding is like cooking – they want to throw a bunch of tasty bits and pieces of code into a file without understanding any of them, stir well, and get something delicious out. It does not work that way.

  4. 4 Matthew W March 16, 2010 at 12:18 PM

    Paul: touché!

    Think you might have been taking his analogies a bit too literally.

    Both are disciplines where there’s a strong component of technical knowledge and technical skills, but also a significant element of creativity in how they’re used. Not the same by any means, but broadly similar enough to be able to appeal to a similar range of personalities.

  5. 5 alexnberra March 17, 2010 at 4:59 PM

    Samidh,
    Just discovered your blog via Facebook. Looks like you started up recently with it. This post is great for my friend who is writes code and is an avid chef, I passed the link along him.

    Lots of ideas in your writing, I like it, very in-depth, makes me think. Let’s see some posts with pictures!

    Hope you are well, running, sunning, funning, in Spring.

    -Alex


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Hello

Welcome to the blog of Samidh Chakrabarti, which revolves around the topic of innovation (from technology to entrepreneurship to policy), sprinkled with ample doses of et cetera.

Popular Posts

    Tweets @samidh

    Archives


    Follow

    Get every new post delivered to your Inbox.