Esolangers

Brainfuck: code that was designed to hurt

One of the most frustrating programming languages was built that way on purpose

Esolangers

Brainfuck: code that was designed to hurt

One of the most frustrating programming languages was built that way on purpose
Esolangers

Brainfuck: code that was designed to hurt

One of the most frustrating programming languages was built that way on purpose

Software is the umbrella term for computer programs and libraries, the coded logic that makes our machines tick. At the root of all software is the code, the instructions that enable a human to tell a machine what to do. This code is written in one of the hundreds of different programming languages — such as C, Java, or Python — each of which has its own eccentricities and context-dependent advantages.

Yet regardless of the programming language being used, the functionality, logic, and efficiency of the language are always paramount — unless, of course, you’re talking about Brainfuck, an esoteric programming language that champions purposefully overcomplicated code.

Created in 1993 by a Swiss physics student named Urban Müller, Brainfuck was an attempt to create a language with the smallest possible compiler. A compiler is a computer program that translates code written in a high-level programming language into something that can be understood by a machine. The closer a programming language is to the computer’s instruction set, which is translated into binary, the less work it needs to do. In other words, to create the smallest compiler (in terms of memory used by the compiler program), Müller had to create a language that was as close to binary as possible.

Müller found the inspiration for Brainfuck in FALSE, the “perverse” programming language developed earlier that year by Wouter van Oortmerssen, a Dutch software engineer now working at Google, with the goal of creating an intentionally confusing Turing-complete language with the smallest possible compiler. While mainstream programming languages like C++ might run on a compiler that is around 2.6 Mb, FALSE’s compiler was only 1,024 bytes, roughly 2,600 times smaller.

The primary advantage of such a small compiler is that it uses less memory on a computer, but that also means coding in a language that is much closer to binary and lacks all the easy-to-understand commands that define mainstream programming languages. But that was exactly the point: Programmers like van Oortmerssen and Müller were creating their esoteric languages for the challenge of it, not the utility.

Brainfuck’s compiler ended up being an order of magnitude smaller than FALSE at only 240 bytes, due to the extreme simplicity of the language. Brainfuck consists of just eight commands: <, >, +, -, [, ], and ,. Despite the simplicity of the Brainfuck lexicon, it is one of the most confusing programming languages out there due to the massive amount of code that needs to be written to execute a simple program.

For example, when a coder wants to learn a new language, one of the first programs they usually teach themselves to write in that language is called “Hello, World!” where the entire point of the program is to display “Hello, World!” on the computer screen. In the case of a common programming language like Python, the code for this program looks like this:


print “Hello, World!” 

Yet that same program written in Brainfuck would look like this:

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

++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

The easiest way to think about how this translates to "Hello, World!" is that certain groupings of commands map out to characters on the ASCII table, which assigns numerical values to standard characters such as letters of the alphabet. If you really want to dive into the details, a good explanation of coding "Hello, World!" in Brainfuck can be found here.

Although Brainfuck is esoteric and confusing by design, it is not necessarily useless. Indeed, it is a Turing complete language, meaning it can theoretically be used to compute any possible problem given enough time and memory, just like regular programming languages. Due to the sheer amount of time it would take to program anything in Brainfuck, however, it is simply not very practical for writing software.

Müller disappeared after dropping his creation on the world, and no one I spoke with had the slightest idea of what happened to him, but a whole community of esolangers (those who design esoteric programming languages) cropped up around Brainfuck over the last two decades, generating dozens of derivative obscure languages.

“For a while it was almost a rite of passage for people getting into esoteric languages to create a Brainfuck derivative first,” said Daniel Temkin, the digital artist behind esoteric.codes, a blog supported by a grant from the Warhol Foundation and the closest thing esoteric programming has to a history museum. “There’s this beautiful minimalism in Brainfuck, but it’s also Turing complete so you can do a lot with it.”

One of the better-known examples of a Brainfuck spinoff is Ook!, a programming language modeled on “Orangutan words” where every character is just the word “Ook” followed by a different punctuation mark. So in this case, “Hello, World!” would look like this:

Hello, World! in Ook!

Hello, World! in Ook!

Then there’s Pi, where errors in the numerical articulation of π map out the code, and Bodyfuck, which codes Brainfuck onto videos of human movement. On this interpretation, a camera records a person moving for input, and different movements (such as waving your hand) correspond to different commands. According to Bodyfuck’s creator Nik Hanselmann, programming in Bodyfuck can be “very punishing,” which feels like an understatement when you watch him code “Hello, World!”:

Although Brainfuck might be said to be ground zero of the esolang scene, it was not the first intentionally obscure language. This honor belongs to INTERCAL, a parody programming language developed by two graduate students at Princeton in 1972. INTERCAL is not only intentionally difficult to understand, but it also pokes fun at the language of code in general, as evidenced by the advice to “please give up” that is used to exit any INTERCAL program:

Despite INTERCAL pioneering parodic coding, it was another two decades before Müller created Brainfuck and kickstarted the esoteric language community proper.

“Esolangers started out as a very small community, a mailing list of people who were really into this weird idea and were trading ideas,” said Temkin. “They came up with a lot of the important early languages that are some of the most important, such as Befunge” — a programming language where the code can be read up, down, left, or right — “and Brainfuck.”

As the esolang community grew throughout the late 1990s and into the new millennium, more and more programmers became acquainted with these languages and started designing new ones for themselves. In the last few years, esoteric languages have also been attracting digital artists like Temkin, who has developed a few esolangs himself, including one that uses the lighting in photographs as source code. To get an idea of what this actually means, here’s what it looks like to program “Hello, World!” in Light Pattern:

It’s not hard to see why artists are attracted to esoteric programming languages, especially ones like Light Pattern or Piet, where the code looks like the abstract paintings made by Piet Mondrian (remarkably, Piet is also Turing complete). Still, Temkin said that many esolangers probably wouldn’t consider their obscure languages “art” in the same way as a painting hanging in MoMA might be called “art.”

“People talk about these languages as experiments that might actually lead to real languages, but most of these are not going to lead to anything useful,” Temkin told The Outline. “I think that most people who make esolangs see it as a form of play. They wouldn’t call it art, but I think of it as art for and by programmers.”

Like coding in a mainstream language, esoteric programming also requires the user to think in a certain way. Yet rather than thinking in terms of utility, esolangs encourage the user to think in ways that are useless and time-consuming, but still logical enough to write complex software (most esolangers stick to creating basic programs like “Hello, World!” however, simply because creating anything much more complex would require an inhuman amount of time and patience).

“The beauty of Brainfuck is not just that it's small and it uses a small number of characters,” Temkin said. “It's the weirdness of trying to think in Brainfuck. It doesn't really have another purpose. It’s just play.”

“A lot of these languages allow for a breakaway of everything you’re supposed to do with a programming language, which is to get things to function the exact right way,” he said. “If a programmer spends their whole day compulsively trying to make things work perfectly, a natural response seems to be wanting to throw some disorder into the code.”

Daniel Oberhaus is a writer based in Phoenix, Arizona, but you can find him on his website.