Hostile design
Languages built to be unpleasant on purpose. The joke is serious. They show which comforts programmers take for granted.
●●○ moderate · where to see it
The idea
Ordinary languages try to help you. Hostile languages try to stop you, and the ways they do it make a neat list of what "helping" means. Familiar syntax, predictable control flow, instructions that mean the same thing each time, programs a human can write at all.
Read the story
The two founding examples.
- INTERCAL (Don Woods and James Lyon, Princeton, 1972), "the compiler language with no pronounceable acronym". Its aim was to resemble no other language. It replaces normal arithmetic with two bit operators, mingle and select, and demands politeness. A program that says
PLEASEtoo rarely is rejected as insufficiently polite, and one that says it too often as overly polite. The 1990 C-INTERCAL revival addedCOME FROM, the mirror image ofGOTO. - Malbolge (Ben Olmstead, 1998), named after the eighth circle of hell in Dante's Inferno. Memory is ternary. Each instruction is decoded from its value plus its address, and after it runs it is scrambled by a substitution table. No human wrote the first Malbolge program. About two years later Andrew Cooke found a Hello World with a beam search, a program written by a program.
Hostility comes in a few kinds.
| Kind | Example |
|---|---|
| Alien syntax | INTERCAL's PLEASE, DO, COME FROM |
| Unstable meaning | Malbolge rewrites each instruction after use |
| Too little to work with | Brainfuck, Unlambda: universal, barely usable |
| Invisible code | Whitespace |
| Unreliable machine | Java2K: functions only probably do what they should; Entropy: data decays as you use it |
| Hard to compile | Befunge was designed to resist compilation, because programs can rewrite themselves |
How it works
INTERCAL's select, written ~, shows the style.
INTERCAL's select, written ~, shows the style. a ~ b keeps the bits of a where b has a 1, and packs them together at the right end. Trace 51 ~ 21.
51 = 1 1 0 0 1 1
21 = 0 1 0 1 0 1 (the mask)
kept: 1 . 0 . 1 (bits of 51 under the mask's 1s)
packed: 101 = 5
So 51 ~ 21 is 5. Nothing here is hard, only unfamiliar, and every simple task (add two numbers) has to be built from it. The core move of hostile design is to keep the machine universal and take away the familiar handles.
Malbolge goes further and takes away stability. A loop body is not the same code the second time round, so you cannot reason about the program by reading it. You have to simulate it. This is why search, not insight, cracked it.
Seen in
- INTERCAL. Alien syntax and manners, the first esolang.
- Malbolge. Instructions that encrypt themselves; programs found by search.
- Befunge. 2D and self-modifying, against compilers.
- Unlambda. Pure combinators, no variables.
- Brainfuck. Mild, minimal hostility.
- Whitespace. Code you cannot see.
- Java2K, Entropy. A machine you cannot trust.
Try this
- Compute
255 ~ 170by hand. (170 is10101010.) - Write down three comforts that ordinary languages give you, and name an esolang that removes each.
- Hard: read about the C-INTERCAL
COME FROM. Rewrite a smallwhileloop using onlyCOME FROMand explain why it is harder to read thanGOTO.
Further
- esolangs.org/wiki/INTERCAL
- Malbolge on Wikipedia
- Donald R. Woods and James M. Lyon, The INTERCAL Programming Language Reference Manual, the original manual.
- See also encoding tricks, self-modifying code, camouflage.