Thursday, August 27, 2009

Elaborate waste of human intelligence

Raymond Chandler once wrote of a particular chess problem that it was "as elaborate a waste of human intelligence as you could find anywhere outside of an advertising agency." Chandler may have been right in his day, but his observation holds no longer. Today, the most elaborate waste of human ingenuity is not designing chess problems that go nowhere or managing political campaigns. It's not even coming up with new financial securities based on bundles of mortgages. It's pathological programming.

What's pathological programming? Normally, computer programming languages are designed so that it's as easy as possible to get the machine to do what you want it to do (given the complexity and range of tasks the language is meant to be dealing with). Pathological languages are designed with the sole purpose of exemplifying structures that are as pointlessly bizarre and/or complicated as possible. It's not an easy task. It actually takes great intelligence to design a computer language to be as stupid as possible.

Perhaps the simplest program you can imagine is a "hello world" program: a bit of code that just prints the words "Hello, world!" on the computer screen. So in BASIC, a "hello world" program is simply

PRINT "Hello, world!"

whereas in R it would be

cat("Hello, world!\n")

And so on. How do pathological languages deal with this task? Well, one of them (called "Chef") has a syntax that requires programs written in it to look like cooking recipes; a "hello world" program written in Chef looks like this:

Ingredients.
72 g haricot beans
101 eggs
108 g lard
111 cups oil
32 zucchinis
119 ml water
114 g red salmon
100 g dijon mustard
33 potatoes


Method.
Put potatoes into the mixing bowl.
Put dijon mustard into the mixing bowl.
Put red salmon into the mixing bowl.
Put oil into the mixing bowl.
Put water into the mixing bowl.
Put zucchinis into the mixing bowl.
Put oil into the mixing bowl.
Put lard into the mixing bowl.
Put lard into the mixing bowl.
Put eggs into the mixing bowl.
Put haricot beans into the mixing bowl.
Liquify contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.


Nice, huh? Then try it in Homespring, a language with syntax that forces programs to look like absurd poetry:

Universe of bear hatchery says Hello. World!.
It powers the marshy things
the power of the snowmelt overrides.


And here we come to the one pathological language that, to me, takes the cake. The true winner of the "most elaborate waste of human intelligence" prize: Malbolge. This language has a structure that is (purposefully) so unintuitive, so devoid of transparency and logic that its own designer was unable to write a successful "hello world" program in it. In fact, as noted by Mark Chu-Carroll (author of the blog I'm linking to in this post), the only way that anyone was capable of writing a "hello world" program in Malbolge was through designing a genetic algorithm that succeeded in creating one.

Before seeing Malbolge, I wasn't aware that such elaborate pointlessness was even possible.

No comments:

Post a Comment