esolang
Learn · Ideas88 languages show it

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 PLEASE too rarely is rejected as insufficiently polite, and one that says it too often as overly polite. The 1990 C-INTERCAL revival added COME FROM, the mirror image of GOTO.
  • 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.

KindExample
Alien syntaxINTERCAL's PLEASE, DO, COME FROM
Unstable meaningMalbolge rewrites each instruction after use
Too little to work withBrainfuck, Unlambda: universal, barely usable
Invisible codeWhitespace
Unreliable machineJava2K: functions only probably do what they should; Entropy: data decays as you use it
Hard to compileBefunge 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

  1. Compute 255 ~ 170 by hand. (170 is 10101010.)
  2. Write down three comforts that ordinary languages give you, and name an esolang that removes each.
  3. Hard: read about the C-INTERCAL COME FROM. Rewrite a small while loop using only COME FROM and explain why it is harder to read than GOTO.

Further

Where to see it