Newbiefuck
Brainfuck as a first interpreter gets it wrong. The [ does nothing.
2016 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Newbiefuck is brainfuck with one command left out. [ does nothing, and ] still jumps back to its matching [ while the cell is not 0. So every loop is a do-while and runs at least once. The specification says most people who write their first brainfuck interpreter build this by accident at some point, because [ is the only command that has to find its partner in code that has not run yet.
Read the story
It is still Turing complete. Copy and move loops such as [-<+>] work as usual whenever the cell is not 0 when they start, and Bitwise Cyclic Tag is translated into Newbiefuck with them.
The machine
| Command | Does |
|---|---|
> < | Move the pointer right or left |
+ - | Add or take 1 from the cell |
. , | Print the cell; read a byte into it |
[ | Nothing |
] | Jump back to the matching [ if the cell is not 0 |
The specification leaves the machine under it open. Cells are bytes that wrap, the tape has no end either way, and , reads 0 at the end of the input.
Example
The example is a brainfuck program that prints Hello.
The example is a brainfuck program that prints Hello. After that the cell is 0, so in brainfuck the next [ skips the second half. In Newbiefuck that [ does nothing and the second half runs once more.
The cat prints a byte, reads the next and goes round while it is not 0. The cat, +[>,.<], never stops, and its truth machine, ,[.], works on the bytes 0 and 1 and not on the digits.
Patterns it teaches
- Turing tarpit: seven working commands, and one of them only jumps back.
- Tag systems: the proof runs Bitwise Cyclic Tag.
Further
See also
Newbiefuck builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Newbiefuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: newbiefuck.
Command line
shib run newbiefuck -e ',[.]' --input '