A machine with eight moving parts.
BFInterpreter runs programs written in Brainfuck — the esoteric language whose entire vocabulary fits on one hand: move, increment, decrement, print, read, loop. Tape size, cell width, and overflow behaviour are all yours to configure.
Releases, changelogs, and packaged builds live on GitLab.
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---. +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
The instruction set, in full
Eight characters. Everything else in the source is a comment, so you can write prose right next to the code and the machine will skip over it.
| Symbol | Name | Effect |
|---|---|---|
| > | shift right | Move the data pointer one cell to the right. |
| < | shift left | Move the data pointer one cell to the left. |
| + | increment | Add one to the byte under the pointer. |
| - | decrement | Subtract one from the byte under the pointer. |
| . | output | Print the byte under the pointer as a character. |
| , | input | Read one character and store it under the pointer; once input runs out, this stores zero. |
| [ | loop start | If the byte under the pointer is zero, jump forward past the matching ]. |
| ] | loop end | If the byte under the pointer is nonzero, jump back to the matching [. |
Install and run
A single Python file, no dependencies. Grab it from the release page above, then run it however suits you.
How the machine is built
One tape, one pointer, one instruction at a time. No hidden registers, no call stack — just a strip of cells and eight ways to touch them.
The tape
A flat array of cells, all zero to start. The pointer begins at cell zero and can only move one cell at a time — there's no addressing, no jumping to an arbitrary index. Everything a program does, it does by walking there.
Wrapping
By default the machine wraps: step past the last cell and you land back on the first; increment past the top of a cell's range and it rolls back to zero. Run with --no-wrap and the same moves raise an error instead — useful if you want a program's bugs to surface immediately rather than silently corrupt neighbouring cells.
Loops
Brackets are the only control flow there is. [ and ] are matched up front, so a jump is a single lookup rather than a scan.