tinyBF
Brainfuck in four characters, so that four commands fit in one byte of program memory.
Michael Gianfreda, 2014 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Michael Gianfreda made tinyBF in November 2014 as a smaller variant of RISBF. Brainfuck has eight commands in four pairs, + -, > <, [ ] and . ,. tinyBF keeps one of each pair and adds a switch, =, that flips which half you mean. Each command then needs only 2 bits.
Read the story
Output and input have no command at all. Flipping twice in a row would do nothing, so == prints instead. And [] is an endless loop no program needs, so |=| reads a byte.
The machine
A tape of byte cells that wrap at 256, growing both ways, a pointer, and a direction that starts as forward.
| Command | Forward | Backward |
|---|---|---|
= | Flip to backward | Flip to forward |
+ | + | - |
> | > | < |
\| | [ | ] |
== | . | . |
\|=\| | , (stays forward) |
Reading past the end of the input gives 0. Every other character is a comment.
Example
The second program is the reverse program.
The second program is the reverse program. In brainfuck it reads +[>,]<-[+.<-]. It reads until the input runs out, then walks back and prints.
Patterns it teaches
- Encoding tricks: a direction bit halves the alphabet, and two sequences that would be useless are reused as I/O.
- Turing tarpit: every brainfuck program translates, so it is just as complete.
Further
See also
tinyBF builds on Brainfuck.
Brainfuck equivalents
Brainfuck derivatives
Write your own in Run Convert a program from tinyBF
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: tinybf.
Command line
shib run tinybf -e '+|>|=|=|>+=|+===>+|' --input 'abc'shib manual tinybfSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/tinybf.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org