Paleoprogramming

TorgoX on 2001-09-05T08:37:18

Dear Log,

About a year or two ago, as I was rewriting HTML::Element (in the HTML-Tree dist), for some reason I stuck a recipe at the end of the source -- after the "__END__" and the "=cut". It's a very good recipe for hummus; it can be a bit of work, but it's almost foolproof, and the result is excellent.

There's various reasons I put it in there:

First off, I figured that HTML::Tree, in my hands, had become such a convoluted mess (especially internally), that maybe people would overlook it all if they did get a really good recipe out of it.
I've heard it said that Mary McCarthy was fond of pointing out that if you got nothing else out of War and Peace, there was always Tolstoy's gourmet recipe for strawberry jam. (Actually it was in Anna Karenina, chapter two; I don't know whether the error is McCarthy's, or the person (Gore Vidal) that I heard quoting her.)

Second off, there's this long tradition of sticking only slightly relevant funny things in program source. But I've not been big on that myself, except for this recipe.

But more importantly and subtly, recipes are sort of interesting, as a genre. Recipes are instructions, just like computer programs -- and almost everything is imperative, either directly ("Now add the beans..."), or indirectly ("If it's too thick, add more oil and blend it some more"). In fact, my favorite explanation of computer programming is that it's like writing recipes to be followed by someone who knows nothing about cooking, and has limited powers of what you'd call "common sense".
And I point out that while you can say just "sautée the spinach" and know what it means, there's all sorts of background knowledge involved, which you have to establish: You have to wash the spinach, but does it greatly matter how much you dry it off? Does it need to be chopped first? How hot should the pan be? Do you sautée in butter, or will that burn too easily, so you need oil -- and is peanut oil OK, or is it too heavy? Should you cover the pan so it sort of steams while it's sautéeing, or does that make it too prone to burning? Once you've actually got it sautéeing, how do you know when it's done? Do you need to immediately transfer it out of the pan and into a cool bowl so that it doesn't overcook, or will that shock it? And so on.

Since recipes are so much like computer programs, you'd think that that would make recipes a very unusual form of language, like legal contracts. But I've always thought that recipes must have figured heavily in the early evolution of real language, so that they're not so strange after all. Recipes convey the first really important abstract concepts that aren't just about things like "look out!", "shhhhh!", "help me!", or even "you go around that way while I chase the boar toward you", and so on. Those things have great "survival value" for people that can say/understand them, but they don't require much in the way of imagining things that aren't actually happening, and so don't exactly stretch language or thought.

But you need real language ability, full of "time displacement" and contingency, to be able to say things like this: "Listen, kid. See this plant? It's good -- its root is very good, but if you eat the skin on the root, you'll feel sick [general contingency!], so scrape the skin off before you eat it. The leaves can be nice and sweet, but if the vine has any leaves bigger than your palm, don't eat any of the plant [conditional imperative!], because I knew someone who did that once, and they died right there [past cause-and-effect, and implication of a general truth from it!]. We should gather more of those roots soon, because if we wait another month [future contingency!], the plants will all be too old to eat. And be careful that you can tell this plant from the one that looks similar but the leaves are fuzzy -- that plant is no good to eat, and even touching it will give you a rash. So ask me if you're not sure."

And that's a recipe, hunter-gatherer style. And being able to say things like that, is how we managed to eat for a few hundred thousand years -- because it sure beats starving. All that other stuff that human language has evolved since then, is all just extra.

That's my story for why programming languages aren't so alien, because we've been making recipes for a very very long time.