Ook!
Brainfuck for orangutans. Three words, Ook., Ook? and Ook!, read in pairs. Eight pairs are Brainfuck's eight commands.
David Morgan-Mar, 2001 · Turing complete: with unbounded memory · ●○○ easy · esolangs.org
Tested with 3 examples · Test method
Run it
Hello World
Expected output
Hello World!
Output
The idea
David Morgan-Mar, who also made Piet and Chef, wrote Ook! as a language that an orangutan could both write and read. The name points at the Librarian of Terry Pratchett's Discworld, an orangutan whose whole vocabulary is "Ook".
Read the story
Underneath, it is Brainfuck with a different spelling. Every pair of Ook words maps to one Brainfuck command, and nothing else changes. So Ook! has exactly Brainfuck's power, and any Brainfuck program can be turned into Ook! by a lookup table.
The joke is the whole point. It is also a clean first example of a pattern that runs through esolangs: keep the machine, change only the surface.
The machine
The machine is Brainfuck's: a tape of byte cells and a pointer. The program is read as a list of Ook. Ook? Ook! words, two at a time.
| Pair | Brainfuck | Does |
|---|---|---|
Ook. Ook? | > | Pointer right |
Ook? Ook. | < | Pointer left |
Ook. Ook. | + | Add 1 |
Ook! Ook! | - | Subtract 1 |
Ook! Ook. | . | Print the cell |
Ook. Ook! | , | Read into the cell |
Ook! Ook? | [ | Loop start |
Ook? Ook! | ] | Loop end |
The ninth pair, Ook? Ook?, is listed on esolangs.org as doing nothing. Whatever is not an Ook word is ignored.
Example
cat, which is ,[.,] in Brainfuck: five commands, ten words.
cat, which is ,[.,] in Brainfuck: five commands, ten words.
Ook. Ook! , read
Ook! Ook? [ while the byte is not 0
Ook! Ook. . print it
Ook. Ook! , read the next
Ook? Ook! ]
The program is brainfuck's ,[.,], the cat.
Checked examples
The brainfuck program ++++++++[>++++++++<-]>+.
Print the letter A
The brainfuck program ++++++++[>++++++++<-]>+. in Ook!.
Expected output
A
Output
Hello World
Expected output
Hello World!
Output
Quirks
- A run stops after 3,000,000 steps.
Try this
- Write
catin Ook! from memory, using only the table. - Swap two neighbouring words in the middle of the
Aprogram. How much of the program changes? Compare with dropping one word. - Write a translator from Ook! back to Brainfuck in another language of your choice, in one line.
Patterns it teaches
- Encoding tricks: a new language made by re-spelling an old one. Compare Unary and Lenguage, which go much further.
- Camouflage: an early, mild case. The program looks like noise from an ape rather than code.
- Turing tarpit: it inherits Brainfuck's tarpit, now with three symbols instead of eight.
Further
- esolangs.org/wiki/Ook!
- David Morgan-Mar's original page on dangermouse.net.
- The language it re-spells: Brainfuck.
See also
Ook! builds on Brainfuck.
Pseudonatural
Brainfuck derivatives
Write your own in Run Convert a program from Ook!
Implementation
Kernel translation, .shib file and command line
Runs on the brainfuck interpreter. Id: ook.
Command line
shib run ook -e 'Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook! Ook? Ook!' --input 'Ook!'shib run shib:ook -e 'Ook. Ook! Ook! Ook? Ook! Ook. Ook. Ook! Ook? Ook!' --input 'Ook!'shib manual ookKernel translation
| Command | Kernel instructions |
|---|---|
Ook. Ook. | PTR LOAD 1 ADD 256 MOD PTR STORE |
Ook! Ook! | PTR LOAD 255 ADD 256 MOD PTR STORE |
Ook. Ook? | 1 MOVE |
Ook? Ook. | -1 MOVE |
Ook! Ook. | PTR LOAD EMIT |
Ook. Ook! | READ 1 ADD DUP IF 1 SUB THEN PTR STORE |
Ook! Ook? | PTR LOAD IF BEGIN |
Ook? Ook! | PTR LOAD NOT UNTIL THEN |
Kernel definition
#! shibboleth 3 seed=ook syllables= plain=off
Ook!: brainfuck spelled with pairs of words; each rule's text holds a space
"Ook. Ook." => PTR LOAD 1 ADD 256 MOD PTR STORE
"Ook! Ook!" => PTR LOAD 255 ADD 256 MOD PTR STORE
"Ook. Ook?" => 1 MOVE
"Ook? Ook." => -1 MOVE
"Ook! Ook." => PTR LOAD EMIT
"Ook. Ook!" => READ 1 ADD DUP IF 1 SUB THEN PTR STORE
"Ook! Ook?" => PTR LOAD IF BEGIN
"Ook? Ook!" => PTR LOAD NOT UNTIL THENSource
- Interpreter
tools/convert/languages.js- Kernel definition
shibboleth/witness/ook.shibonshibboleth/kernel.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org