← Pablo Murad

A different kind of computer I: esoteric programming languages

The first part of A different kind of computer, a series about computing off the beaten path. It starts with esoteric programming languages: where they came from, Brainfuck up close with a tiny interpreter, where to begin, and how to design and publish a language of your own.

A black background with a Brainfuck program in large monospace type, four lines of plus and minus signs, angle brackets and dots, with the two square brackets of its loop in red. Under it, a small caption reads "a different kind of computer · I · esoteric languages", with the I in red, and a terminal line reads "$ python3 bf.py hello.bf → Hello World!".
Contents

This is the first part of A different kind of computer, a series about the corners of computing that were never meant to be productive and turned out to be some of the most interesting places to spend time in. Along the way it will go through esoteric programming languages, permacomputing, fantasy computers and fantasy consoles, and whatever else shows up on the way.

Part I starts with esoteric programming languages, esolangs for short: languages made to be strange on purpose.

What makes a language esoteric #

A normal programming language is designed to help people get work done. An esolang is designed for something else: a joke, a puzzle, an idea pushed as far as it goes, or a piece of art. Some remove almost everything a language usually has and keep just enough to stay Turing complete.1 Some hide programs inside things that don't look like programs at all, like paintings, recipes, plays or music. And some exist only to make programming as hard as possible.

Nobody writes a payroll system in them, and that's the point. Taking a language apart this way shows what a language really needs, which parts of programming are habit and which are necessity, and how little a machine needs to compute anything at all.

A short history #

It began as a parody. In 1972, two Princeton students, Don Woods and James M. Lyon, wrote INTERCAL, a language meant to be unlike every language they knew.2 Its best-known rule is about manners: statements can start with PLEASE, and the compiler rejects a program that says it too rarely, for being impolite, or too often, for being excessive. For years INTERCAL existed mostly as a paper manual. In 1990, C-INTERCAL brought it to Unix, and the revival got a lot of people interested in designing strange languages on purpose.

1993 was a busy year. Wouter van Oortmerssen made FALSE, a tiny stack language with a compiler of 1024 bytes. That inspired Urban Müller, a Swiss student, to go smaller: Brainfuck, eight commands, with a compiler for the Amiga that took 296 bytes and later 240. The same year Chris Pressey made Befunge, also for the Amiga, where the program is a two-dimensional grid and arrows steer the instruction pointer around it. It was designed to be as hard to compile as possible.3 This is a whole Befunge program:

"!dlroW ,olleH">:#,_@

The quotes push the text onto a stack, backwards, so it comes out in the right order. Then >:#,_ is the loop. While the top of the stack isn't zero, the pointer bounces back and forth through it, printing one character per turn, and when the stack runs empty, _ sends the pointer right instead, onto @, which ends the program. It prints Hello, World!.

In 1998, Ben Olmstead made Malbolge, named after the eighth circle of hell in Dante's Inferno and built to be the hardest language possible. Its code changes itself as it runs, and what an instruction does depends on where it sits in memory. It took two years for the first Malbolge program to appear, and no person wrote it: it was found by a beam search program written by Andrew Cooke, in Lisp.

After that the field went everywhere at once. The table has some of the landmarks:

Source
---
/* cssv:title Some landmarks */
/* cssv:description A few esoteric languages and events, by year, with the idea behind each one. */
table { width: 100%; font: 15px/1.45 source-serif-4, Georgia, serif; color: #111; border-collapse: collapse; }
th { font: 600 11px/1.4 ibm-plex-mono, ui-monospace, monospace; text-transform: uppercase; letter-spacing: 0.06em; color: #666; text-align: left; padding: 0 0.7em 0.4em 0; border-bottom: 1px solid #111; }
td { padding: 0.45em 0.7em 0.45em 0; border-top: 1px solid #e6e6e6; vertical-align: baseline; }
tbody tr:last-child td { border-bottom: 1px solid #111; }
td[data-col="year"] { font: 600 13px/1.5 ibm-plex-mono, ui-monospace, monospace; color: #d93a2b; white-space: nowrap; }
td[data-col="language"] { font-weight: 600; }
---
year,language,the idea
1972,INTERCAL,"A parody of every language its authors knew, with a politeness rule"
1990,C-INTERCAL,INTERCAL finally runs on Unix
1993,FALSE,A stack language with a 1024-byte compiler
1993,Brainfuck,"Eight commands, one tape, a compiler under 300 bytes"
1993,Befunge,"A program is a grid, and arrows move the pointer"
1998,Malbolge,Built to be the hardest language there is
2001,HQ9+,Four commands that each solve one classic exercise
2002,Whitespace,"Only spaces, tabs and line breaks count"
2002,Chef,Programs are cooking recipes
2005,Esolang wiki,The community gets a home
2007,LOLCODE,Programs written in lolcat speech
2009,Velato,Programs are MIDI files

HQ9+, by Cliff L. Biffle, is a joke about how languages get judged: H prints Hello World, Q prints the program's own source, 9 prints the lyrics of 99 Bottles of Beer, and + increments an accumulator that nothing can read. It solves three classic exercises in one character each and can do nothing else.

Whitespace came from Edwin Brady and Chris Morris at the University of Durham, and Slashdot reviewed it on April Fools' Day 2003. Its only commands are spaces, tabs and line breaks, and everything else in the file is a comment, which means a Whitespace program can hide inside the indentation of a program in another language. In an editor that highlights the invisible characters, it looks like this:

A Whitespace program open in the vim editor with highlighting turned on: spaces show as blue bars and tabs as red blocks, in rows of different lengths. The only readable text is the comment "Say hello." at the top left, and the status line at the bottom reads "7,8-32 Anfang".

David Morgan-Mar wrote two of the most loved ones. In Chef, a program is a recipe, with ingredients as variables and mixing bowls as stacks, and the design goal is that recipes should work and also taste good.4 In Piet, named after Piet Mondrian, a program is an image. The interpreter walks from one block of colour to the next, and the change in hue and lightness between two blocks decides the instruction. This painting prints "Hello world":

A Piet program that prints "Hello world": a square grid of bright coloured blocks in yellow, blue, magenta, green, cyan, red and pale tints, framing a black area with a pale green cross shape in the middle.

The Shakespeare Programming Language, by Jon Åslund and Karl Wiberg, turns programs into plays, where the variables are characters who talk to each other on stage. LOLCODE, made in 2007 by Adam Lindsay at Lancaster University, is written the way lolcats talk:

HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE

And Velato, made by Daniel Temkin in 2009, uses MIDI files as source code, so a program is also a piece of music. Temkin also runs esoteric.codes, the best place to read interviews with the people behind these languages, Ben Olmstead and Wouter van Oortmerssen among them.

Brainfuck, up close #

Brainfuck is the best language to start with, because the whole machine fits in your head. There's a tape of cells, usually 30,000 of them, each holding a byte that starts at zero. A pointer sits on one cell. Eight characters do everything, and any other character in the file is a comment:

commandwhat it does
>move the pointer one cell to the right
<move the pointer one cell to the left
+add 1 to the current cell
-subtract 1 from the current cell
.print the current cell as a character
,read one character into the current cell
[if the current cell is 0, jump past the matching ]
]if the current cell isn't 0, jump back to the matching [
Source
| command | what it does |
|---------+-------------------------------------------------------|
| > | move the pointer one cell to the right |
| < | move the pointer one cell to the left |
| + | add 1 to the current cell |
| - | subtract 1 from the current cell |
| . | print the current cell as a character |
| , | read one character into the current cell |
| [ | if the current cell is 0, jump past the matching ] |
| ] | if the current cell isn't 0, jump back to the matching [ |

That's the entire language. Writing an interpreter for it is the classic first step, and it fits in under twenty lines of Python:

import sys
code = [c for c in open(sys.argv[1]).read() if c in "+-<>.,[]"]
jump, stack = {}, []
for i, c in enumerate(code):
 if c == "[": stack.append(i)
 if c == "]": j = stack.pop(); jump[i], jump[j] = j, i
tape, ptr, pc = [0] * 30000, 0, 0
while pc < len(code):
 c = code[pc]
 if c == ">": ptr += 1
 elif c == "<": ptr -= 1
 elif c == "+": tape[ptr] = (tape[ptr] + 1) % 256
 elif c == "-": tape[ptr] = (tape[ptr] - 1) % 256
 elif c == ".": sys.stdout.write(chr(tape[ptr]))
 elif c == ",": tape[ptr] = ord(sys.stdin.read(1) or "\0")
 elif c == "[" and tape[ptr] == 0: pc = jump[pc]
 elif c == "]" and tape[ptr] != 0: pc = jump[pc]
 pc += 1

The first loop matches every [ with its ] before running anything, so jumps are instant. The second loop is the machine itself. Two classic programs to test it, the Hello World from Wikipedia and cat, which copies its input to its output:

$ cat hello.bf
++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++
..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.
$ python3 bf.py hello.bf
Hello World!
$ echo "small web" | python3 bf.py cat.bf
small web
Source
$ cat hello.bf
++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++
..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.
$ python3 bf.py hello.bf
Hello World!
$ echo "small web" | python3 bf.py cat.bf
small web

cat.bf is five characters long: ,[.,]. Read a character, and while it isn't zero, print it and read the next.

The trick in almost every Brainfuck program is the loop that moves numbers around. This one adds 2 and 3 and prints the result:

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

It starts with 2 in the first cell and 3 in the second. The loop [<+>-] runs while the second cell isn't zero, moving one unit to the left each time, so the first cell ends at 5. Right before that loop starts, the tape looks like this:

tape tape 2 3 0 0 0 ... ptr pointer ptr->tape:b
Source
digraph tape {
rankdir=TB;
node [fontname="Helvetica", fontsize=12, margin="0.4,0.12"];
tape [shape=record, label="<a>2|<b>3|0|0|0|..."];
ptr [shape=plaintext, label="pointer"];
ptr -> tape:b;
}

A digit has to be printed as its ASCII code, and 5 is character 53, so the second loop adds 6 times 8 to the first cell before . prints it:

$ python3 bf.py add.bf
5
Source
$ python3 bf.py add.bf
5

That second loop is multiplication: six turns, adding 8 each time. Nearly everything else in Brainfuck grows out of these same few patterns.

Where to start #

The Esolang wiki has been the community's home since April 2005 and documents thousands of languages. The language list is the place to browse, and the joke language list collects the ones that can't really be programmed in, or that only rename another language, which is a useful map of ideas that have already been done.

An even smaller first target than Brainfuck is Deadfish, created by Jonathan Todd Skinner: one accumulator and four commands. i adds one, d subtracts one, s squares, o prints, and the value resets to zero whenever it reaches -1 or 256. The whole interpreter:

import sys
acc = 0
for c in sys.argv[1]:
 if c == "i": acc += 1
 elif c == "d": acc -= 1
 elif c == "s": acc *= acc
 elif c == "o": print(acc)
 if acc in (-1, 256): acc = 0
$ python3 deadfish.py iissiso
289
$ python3 deadfish.py iisssio
1
Source
$ python3 deadfish.py iissiso
289
$ python3 deadfish.py iisssio
1

The second program squares its way to 256, hits the reset rule, and prints 1 instead of something enormous. That little rule is the whole personality of the language.

To try languages without installing anything, Attempt This Online runs code in the browser for a long list of languages, esolangs among them. It started as a replacement for the older Try It Online, which still works but has fallen out of date.

For company, the community portal of the wiki lists the places people meet: the #esolangs channel on Libera.Chat, which it calls the official home for real-time discussion, an Esolangs Discord server, The Tarpit chat room on Code Golf & Coding Challenges, and, for anyone with a newsreader, the Usenet group alt.lang.intercal, which discusses INTERCAL and other esoteric languages to this day.

There are two good books. Strange Code, by Ronald T. Kneusel (No Starch Press, 2022), goes through the classics and walks through building two new languages from scratch. Forty-Four Esolangs, by Daniel Temkin (MIT Press, 2025), treats esolangs as art, with languages from the last fifteen years and some designed for the book.

Making your own #

The easiest way to make a new language is to rename another one. This short script turns Brainfuck into words and back:

import sys
words = {"+": "more", "-": "less", ">": "next", "<": "back", ".": "say", ",": "hear", "[": "while", "]": "again"}
back = {w: c for c, w in words.items()}
text = open(sys.argv[2]).read()
if sys.argv[1] == "to": print(" ".join(words[c] for c in text if c in words))
else: print("".join(back[w] for w in text.split()))
$ python3 words.py to add.bf
more more next more more more while back more next less again more more more more more more while back more more more more more more more more next less again back say
$ python3 words.py to add.bf > add.words
$ python3 words.py from add.words > add2.bf && python3 bf.py add2.bf
5
Source
$ python3 words.py to add.bf
more more next more more more while back more next less again more more more more more more while back more more more more more more more more next less again back say
$ python3 words.py to add.bf > add.words
$ python3 words.py from add.words > add2.bf && python3 bf.py add2.bf
5

It works, and it's also exactly the kind of language that ends up on the joke list. The wiki is full of Brainfuck with the eight symbols swapped for something else. It's a fine exercise, but a language becomes interesting when the idea changes how programs are written, not only how they're spelled.

A few questions help find that idea:

  1. What's the constraint? Fewer commands, one kind of data, programs that are also something else, a memory that forgets, time running backwards. One strong limit beats five weak ones.
  2. What does the machine look like? A tape, a stack, a queue, a grid, a single number, a set of rewriting rules. Draw it before writing any code.
  3. What does a program look like on the page? Text, an image, sound, a recipe, a poem. This is where most of the personality lives.
  4. Can it compute anything? Proving Turing completeness usually means showing how to translate Brainfuck, or another known language, into yours. If it can't, say so; the computational class of many languages is still an open question.
  5. Does it already exist? Search the wiki first. Most first ideas have been done, and the variation that makes yours different is usually better than the original idea anyway.

Then the work goes in a fairly fixed order: write a short specification, write an interpreter, and write the three programs most language pages show, Hello World, cat and a truth machine.5 A Python interpreter is plenty. If the language has a visual side, make the reference examples look good too.

Publishing is open to anyone. Create an account on the Esolang wiki, read the help page for language creators linked from the front page, and write the article: who made it, when, how it works, the example programs, the computational class, and a link to the interpreter. Then share it in #esolangs or the Discord, where people will find the bugs in the spec within the hour, which is half the fun.

What to do with them #

Golf. On Code Golf & Coding Challenges, the goal is to solve a task in as few bytes as possible, and whole languages exist only for that.

Quines, programs that print their own source, are a rite of passage in any language, and harder in an esolang. Polyglots go further: a single file that runs as two languages at once, which Whitespace makes almost too easy.

Art. Piet programs look like paintings, Velato programs are music, and people have actually baked Chef recipes. A program can be a poem, a score or a picture that also runs.

And study. Writing a Brainfuck interpreter, then a compiler that turns it into C or assembly, teaches more about how languages work than many textbooks. The language is small enough that there's nowhere to hide.

The next part of this series leaves languages behind and goes to fantasy consoles: machines that never existed, with limits chosen on purpose.

Sources #

Notes

  1. A language is Turing complete when it can compute anything a computer can compute, given enough memory and time. Brainfuck is; most of the joke languages aren't. ↩

  2. The name stands for "Compiler Language With No Pronounceable Acronym". ↩

  3. The name Befunge started as a typo in an online conversation. The original Befunge-93 limits programs to a grid of 80 by 25 and isn't Turing complete; the later Funge-98 lifts the limits. ↩

  4. Morgan-Mar points out that the sample Hello World recipe asks for 101 eggs and 111 cups of oil, which makes a lot of food for one person. ↩

  5. A truth machine reads one character. If it's 0, it prints 0 and stops; if it's 1, it prints 1 forever. It's a tiny test of input, output, branching and looping in one program. ↩