Spoon
Brainfuck written in 0 and 1, with the most common command the shortest.
S. Goodwin, 1998 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
S. Goodwin made Spoon in 1998. It is brainfuck compressed with Huffman coding. Each command gets a string of bits, and the commands programs use most get the shortest ones. + is a single 1. No code is the start of another, so the bits split into commands one way only, with no separators.
Read the story
Spoon adds two commands of its own. One prints the whole memory, one ends the program at once.
The machine
A tape of byte cells that wrap at 256, growing both ways, and a pointer. Only 0 and 1 count; any other character, such as a line break, is ignored.
| Bits | Does |
|---|---|
1 | + |
000 | - |
010 | > |
011 | < |
00100 | [ |
0011 | ] |
001010 | . |
0010110 | , |
00101110 | Print the memory (not supported; it stops the run) |
00101111 | End the program |
Reading past the end of the input gives 0.
Example
The second program is ,.,., which reads a byte and prints it, twice.
The second program is ,.,., which reads a byte and prints it, twice.
Patterns it teaches
- Encoding tricks: a prefix code needs no separators and can be read from left to right without looking back.
- Turing tarpit: it is brainfuck, so it is just as complete.
Further
See also
Spoon builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Spoon
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: spoon.
Command line
shib run spoon -e '00101100010100010110001010' --input 'hi'shib manual spoonSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/spoon.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org