Esoteric Programming: Minimalism to the Extreme

If you’re not a professional coder, but had some experience learning a programming language (e.g. slogging through a course back in college), you probably would appreciate the efforts of one particular camp of esoteric language designers — the minimalists. How much of this fancy stuff do we really need? Could I get by without a “dictionary” data type? Do we really need both “for” loops and “while” loops? Turns out, you can get by with very little. And how little you need speaks to some deep issues in theoretical computer science, issues that these language-inventors think very carefully about.  And which we’ll completely ignore.

Before We Start…  a Standard Language

Here (and throughout our tour of ridiculous languages) we’ll be giving you a taste for the bizzarity of each language by showing you a snippet of source code from a real program.  We’ll follow the age-old tradition, and pick the very simple “Hello World” program — perhaps the most common programming exercise for the novice user, the sole point of this program is to greet the user with its title phrase printed to the screen.  It’s a pretty simple program.  Hard to en-complicate.  Here, check out how you’d write “Hello World” in the C programming language:

/* Hello World program */
#include
main()
{
    printf("Hello World");
}

A little weird-looking, if you’re unfamiliar with programming, but things generally seem logical.  In C, blocks of code are separated by curly brackets, to help you the programmer stay organized — a practice the esoteric languages will take great pains to avoid.  Comments are surrounded by the /* …  */  symbols, and are meant to leave little notes for the code reader to help explain what the code is doing — obviously this is the last time we’ll see something that helpful on our tour. The word “printf” has to do with printing something out, either to the screen or to a file. You probably would have guessed that, since the name was chosen to be informative. Needless to say, we won’t be seeing that anymore.

Now that you’re an expert in C, let’s move on to learn more about example minimalist languages…

Unlambda

This is the very first esoteric language I came across — I was looking up how to do something more easily, and stumbled across the completely opposite concept — let’s make our lives harder by making the most pared-down, bare bones language possible!  Unlambda is designed to be a “pure” language, getting by with as minimal a set of features as possible and still being Turing complete (a concept so cool it deserves an article of its own, someday).  You don’t get any fancy data structures like classes or lists to store your data. In fact, good luck storing data — you don’t get variables at all. You also don’t get the usual fundamental programming commands you’re used to, like for-loops or if-then statements.

So what do you get? Functions! Functions that take other functions as inputs, because of course you don’t have any variables. There are some built-in functions, but you can create your own custom functions. (You just can’t save them or give them names.) Unlike other languages we’ll see later, Unlambda isn’t totally for fun — it’s partly an exercise in theoretical computer science ideas and formal logic. If you’ve had your wheaties, read more on lambda calculus (of which unlambda is an implementation), and binary lambda calculus.  This is one of those times at timeblimp.com where I declare a topic too hard to understand for the moment, but that I’ll do some homework and get back to you later.  Well, by now, my regular readers will know, I won’t get back to it later.

Hello World in Unlambda:

`r```````````.H.e.l.l.o. .w.o.r.l.di

Disappointed by how normal that looks?  It looks a little odder than C’s version, arguably — but you can still recognize the phrase “Hellow World” in there.  Well, then parse this sucker:

```s``s``sii`ki
  `k.*``s``s`ks
 ``s`k`s`ks``s``s`ks``s`k`s`kr``s`k`sikk
  `k``s`ksk

That abomination prints out the Fibonacci numbers.

False

Let’s move on to learn about one of the very first esoteric languages, called “FALSE”.  Wouter van Oortmerssen wanted to make a language with as small of a compiler as possible. And he got it — his language FALSE (named after his favorite boolean value) needs a compiler only 1024 bytes in size.  False was an early member of the club of esoteric languages (Wouter made it in 1993), and was the inspiration for several other languages we’ll meet soon enough.
Hello World in FALSE:

"Hello, World!
"

Quite possibly the most straightforward “Hello World” we’re going to see in this article. Much more straightforward than C’s, even. But FALSE can look pretty horrid, don’t you worry — commands are so compact, that it becomes pretty unreadable pretty quickly. For example, here’s a program that writes out all prime numbers between 0 and 100:

99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#

Brainfuck

One of the most famous and awesomely-named esoteric languages, Brainfuck is astoundingly minimalist.  There are only eight commands.  Total.  Compare that to those humongous books on Java or Ajax at the bookstore — the manual for Brainfuck could be written in the blank spaces on 20-sided dice.  And the eight commands have wonderfully opaque names — in fact not names at all, just punctuation.  Here is the full list of all possible commands in brainfuck:

 > < + – . , [ ]

The simplicity of the command set means that it’s easy to write a compiler — in fact the original goal of Brainfuck (created by Urban Muller in 1983) was to make the compiler really small — various compiler versions exist of just a few hundred bytes. But it’s a huge pain in the ass to write the program in the first place, because the commands are so elementary that any reasonably-complex action requires a ton of manipulation.  I didn’t tell you what those eight commands actually do, because they each do rather dry low-level tasks involving manipulation of individual bits.  None of them correspond to C’s “printf”, for example — the Brainfuck eight commands are the atomic programming bits from which you have to create the equivalent of “printf”.

Despite being so simple, brainfuck is Turing complete — given enough time and memory, it can do exactly what any other computer can do, albeit much more inefficiently.

Hello World in Brainfuck:

++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++
 ..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.

Now that’s obscure!  Looks like someone trying to render a train accident in ASCII art.  Nevertheless, it’s a valid program, and will print out “Hello World” for you if you compile it.

 

Ready for more? Then move on to our next group: Languages that are Funner To Read

 

© 2011 TimeBlimp Thith ith a pithy statement. Suffusion theme by Sayontan Sinha