Tape and Stack Languages

Ook and Other Brainfuck Reskins

See how renaming Brainfuck's eight commands, as Ook does with its three word forms, makes a new-looking language that is still the same underneath.

On this page
  1. The same machine in a different costume
  2. How Ook works
  3. Why a rename changes nothing important
  4. A tiny translator
  5. What reskins vary
  6. Reskin, dialect or new language?
  7. What this teaches about syntax and semantics
  8. Readability
  9. Try it yourself

The same machine in a different costume

Brainfuck has eight commands. Take those eight, give each a new spelling, and you have what is called a reskin: a language that looks nothing like Brainfuck on the page but behaves identically underneath. Ook is the best-known example. It is written with the words Ook followed by a period, question mark or exclamation mark, and it is presented as a language suited to an orangutan.

A reskin is a good case study in the difference between how a language looks and how it works.

How Ook works

Ook has three tokens: “Ook.”, “Ook?” and “Ook!”. Each command is a pair of these tokens, so there are nine possible pairs, and eight of them correspond to the eight Brainfuck commands. For example, the pair “Ook. Ook.” is the equivalent of the increment command +, and “Ook! Ook!” is the equivalent of the decrement -. The remaining pairs are assigned to the pointer moves, the input and output commands, and the two bracket commands, following a fixed table published by the language’s author.

A short Ook program is therefore a long, repetitive stream of the same word with varying punctuation. Where a Brainfuck program of ten commands fits on a short line, the Ook version runs to twenty words. This makes the code longer without changing what it does.

Why a rename changes nothing important

Everything that makes Brainfuck work is in its semantics: a tape of cells, a pointer, increment and decrement, input and output, and a loop that tests for zero. The symbols are only labels. A translator between Brainfuck and Ook needs no understanding of programs. It reads one command at a time and writes the matching replacement. The same program in either language gives the same output, and any program that halts in one halts in the other.

This is a one-to-one mapping, which is the simplest kind of language translation. It also means that all the usual patterns for clearing and copying cells carry over unchanged, and so do the portability concerns about cell size and end of input.

A tiny translator

The translation can be written as a lookup table. A script reads each Brainfuck character, looks it up in a dictionary of eight entries, and appends the matching words. Going the other way is the same idea in reverse, except that the reader must group tokens in pairs. Ignoring any character that is not a command is a common rule, and it lets comments sit inside programs, so the translator usually keeps or drops them by choice.

Because of this simplicity, many reskins in the hobby are produced almost as a joke, sometimes in minutes. The effort goes into the theme, not the machinery.

What reskins vary

Different reskins change different things:

  • Vocabulary: words, animal sounds, emoji or other symbols in place of punctuation.
  • Token grouping: a command might be one word, a pair, or a longer phrase.
  • Whitespace and punctuation rules: whether extra characters are ignored.
  • Presentation: a program might read like a sentence, a menu or a poem.

The joke is often tied to a theme, which is why these appear alongside joke languages in discussions of esolang culture. Choosing the theme is a form of language naming: a good name and a memorable vocabulary matter more than any technical novelty.

Reskin, dialect or new language?

The line between a reskin and a dialect depends on whether behavior changes. If only the spelling differs, it is a reskin. If the cell size, the tape or the commands themselves differ, it is a dialect, or a different language altogether. Careful writers say that Ook is a reskin of Brainfuck for exactly this reason, while languages that add commands or change the memory are called derivatives.

What this teaches about syntax and semantics

Reskins are a pure demonstration of the split between syntax and semantics. Syntax is the surface form: which strings are legal programs. Semantics is what a legal program does. Ook has different syntax and the same semantics. Other esoteric languages go the other direction, with simple syntax and unusual semantics. A language like Whitespace is a related idea in a different guise, since it uses invisible characters for its commands, though its command set is its own and not a renaming of Brainfuck’s.

Readability

A reskin usually makes code readability worse, not better. Ten commands become twenty tokens, and a human reader sees a wall of identical words. That can be the point: the humor comes from how absurd it is to write serious logic this way. Still, the underlying Brainfuck commands are easy to see once you map them back, and most programmers find that after translating a short example by hand the whole thing stops seeming mysterious.

Try it yourself

Pick a theme, choose eight words, and write down the mapping. Translate the program that prints one letter, then check that the output matches. Then write a translator and run it on something longer. You will have invented a language, in a small way, and learned how little separates one language from another when only the names differ.

The complete guide to tape and stack languages

Tape and Stack Based Esoteric Languages
Read the guide

Keep exploring

Guides from other topics

All topics →

What Is Funge-98?

Funge-98 generalizes Befunge into a larger, better-defined family of grid languages. Learn its goals, its main differences from Befunge-93, and why it matters.

Funge-98 5 min read