Turing tarpit
A language that can compute anything, and makes everything painful. Universal, but stuck in the tar.
●○○ easy · where to see it
The idea
The phrase comes from Alan Perlis's Epigrams on Programming (1982). His point is that in a tarpit everything is possible, yet nothing interesting is easy.
Read the story
Perlis meant it as a warning about real languages. Esolang makers took it as a design goal. How few instructions can a language have and still be Turing complete? The answer turns out to be very few. Eight for Brainfuck, one for Subleq, two combinators for Unlambda's core, a single combinator for Iota.
A tarpit is a proof of a surprising fact, turned into a toy. The fun is in the gap between "this can compute anything" and "it took me an hour to print a letter".
How it works
Every tarpit keeps the two things universality needs and throws away the rest.
Every tarpit keeps the two things universality needs and throws away the rest.
- Unbounded memory you can change, a little at a time (a tape, counters, a string, a term).
- A conditional loop or jump, to repeat until something is zero.
Everything else, such as numbers bigger than one, named variables, arithmetic, functions and strings, is built by hand out of those two.
Compare adding one number to another.
b = b + a
[->+<] while cell 0 is not zero: take 1 from it, add 1 to cell 1
The Brainfuck loop is the whole addition. Multiplication is a loop inside a loop. Printing A (65) is a loop that adds 8 eight times, plus one. Every high-level idea becomes an idiom you build from scratch, which is why tarpit programmers trade idiom lists like recipes.
Tarpits fall into rough kinds.
| Kind | Memory | Example |
|---|---|---|
| Tape | Cells and a pointer | Brainfuck, Smallfuck, Boolfuck |
| One instruction | Numbers in memory | Subleq, BitBitJump |
| Counters | A few huge numbers | FRACTRAN; see counter machines |
| Queue | A string read at the front, grown at the back | Bitwise Cyclic Tag; see tag systems |
| Combinators | A tree of functions | Unlambda, Iota, Jot; see combinators |
Seen in
- P′′. Böhm's 1964 language, the first tarpit before the word existed.
- Brainfuck. The famous one; eight characters.
- Smallfuck and Boolfuck. Brainfuck shrunk to bits.
- Subleq and BitBitJump. One instruction each.
- FRACTRAN. A list of fractions and nothing else.
- Bitwise Cyclic Tag. Two commands on a queue of bits.
- Unlambda, Iota, Jot. Functions only.
Try this
- In Brainfuck, write
[->++<]. What does it compute? What about[->+>+<<]? - Pick a tarpit and write down the two things from "How it works". Where is its unbounded memory, and where is its conditional loop?
- Hard: design a tarpit with fewer than eight Brainfuck-style commands. Which ones can you merge? (Look up Boolfuck afterwards.)
Further
- esolangs.org/wiki/Turing_tarpit
- Alan Perlis, "Epigrams on Programming", SIGPLAN Notices, 1982 (epigram 54).
- See also Turing completeness, one instruction.