esolang

BFI

Brainfuck without brackets. A loop is a procedure that loads itself again.

Morex, 2009 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello World!

The idea

Morex made BFI, BrainFuck Itself, in 2009, after brainfuck and GASOIL. The [ and ] are gone and there is no instruction pointer. The program sits on a stack of commands. Each step takes the top command off and runs it, so the program eats itself as it goes, and the run ends when the stack is empty.

Read the story

The source is cut at each ; into procedures numbered from 0. Only procedure 0 is on the stack at the start. ? puts another procedure on top when the current cell is not 0. A procedure that ends with ? loads itself again and again, which is a loop, and since its last command is already off the stack the stack does not grow. The specification says recursion is the only way to loop.

The machine

CommandDoes
> <Move the data pointer
+ -Add or take 1 from the cell
. ,Print or read a byte
} {Move the routine pointer up or down
?If the cell is not 0, load the procedure under the routine pointer

Every other character is ignored. Cells are bytes, the end of input reads as 255, and the tape starts at cell 0.

Example

The Hello World program has three procedures.

The Hello World program has three procedures. Procedure 2 adds 4, and procedure 1 is the loop of brainfuck's usual Hello World, >+++++++>++++++++++>+++>+<<<<-, written with calls to procedure 2.

The bubble sort is a brainfuck sort from The Brainfuck Archive, turned into twelve procedures. Its reading loop stops when ,+ gives 0, which is why the end of input reads as 255.

Expected: aeglnos

Patterns it teaches

  • Turing tarpit: nine commands, and the specification shows any brainfuck program can be turned into BFI.
  • Stack machines: the stack holds the program, not the data.

Further

BFI builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from BFI

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: bfi.

Command line

shib run bfi -e '++}}??{?>++.>+.+++}?..+++.>++.<<+++???.>.+++.------.--------.>+.>.;
>+++}?>++??{>+++>+<<<<-?;
++++ '
shib manual bfi

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/bfi.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org