Boolfuck

Dialect of programming language Brainfuck

Boolfuck is a dialect of Brainfuck which operates on bits instead of bytes. Unlike Smallfuck, it keeps I/O commands, so it’s a usable dialect. The commands are:

  • + : flip the current bit (to distinguish from Smallfuck);
  • > : increment the data pointer (move it to the next cell to the right);
  • < : decrement the data pointer (move it to the next cell to the left);
  • [ : “begin loop”;
  • ] : “end loop”;
  • , : read a bit from input;
  • ; : write a bit to output (to distinguish from Brainfuck).

The dialect operates with bits, but input and output streams work with characters. This is resolved by reading/writing the characters bit-by-bit, in little-endian order, meaning that bits are read/written from least significant to most significant.

Another notable difference from Brainfuck is that the memory tape is infinite in both directions. Brainfuck program can be translated into Boolfuck (but not vice versa) by using the following mapping of commands:

  • + -> >[>]+<[+<]>>>>>>>>>[+]<<<<<<<<<
  • - -> >>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]<<<<<<<<<
  • > -> >>>>>>>>>
  • < -> <<<<<<<<<
  • [ -> >>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]
  • ] -> >>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]
  • . -> >;>;>;>;>;>;>;>;<<<<<<<<
  • , -> >,>,>,>,>,>,>,>,<<<<<<<<

Boolfuck was invented by Sam Hughes in 2006.

Examples:

Hello, World!:

Example for versions EsCo 0.511 (Brainfuck)

Example for dialect Boolfuck.

H ;;;+;+;;+;+;
e +;+;+;+;;+;;+;
l ;;+;;+;+;;+;
l ;;+;;+;+;;+;
o +;;;;+;+;;+;
comma ;;+;;+;+;+;;
space ;;;;;+;+;;
W +;;;+;+;+;+;+;
o +;;;;+;+;;+;
r ;+;+;;+;;;+;
l ;;+;;+;+;;+;
d ;;+;+;;+;;+;
! +;+;;;;+;+;;
\n ;+;+;+;