Boolfuck

From Esolang
Jump to navigation Jump to search

Boolfuck is an esoteric programming language based on Brainfuck, but operating only on bits. It does, however, provide input and output.

Commands

Command Meaning
+ Invert the bit that the current tape cell holds.
, Input.
; Output.
< Move tape head left.
> Move tape head right.
[ Jump past matching ] if current tape cell holds 0.
] Jump back to matching [.

Computational class

Boolfuck can be shown to be Turing-complete by reduction from Brainfuck. Each Brainfuck program maps to a Boolfuck program - so anything that can be expressed in Brainfuck can also be expressed in Boolfuck - and Brainfuck is known to be Turing-complete. More details on the reduction can be found at the Boolfuck website, listed below.

Differences from Brainfuck

  • Works with bits not bytes. Each cell is 1-bit and wrapping, so - is removed.
  • The output character is ; not ..
  • The input is read in little endian mode and reads a single bit at a time.
  • Output is stored to a stream, then outputted in little endian mode.

IO explanation

The IO in Boolfuck works via streams. Input (as before mentioned) is read in little endian and reads a single bit at a time. Such that if a user was to input 0 the bits would be read as 00001100. The output is decided one bit at a time, such that a programmer may use a single bit of memory to send an entire byte of data to the output stream. For example to print 1 you may use +;+;;;+;;+;; (to generate the bit stream 10001100) assuming the bit is a zero to begin with.

Examples

Here is a sample Boolfuck program; it outputs Hello, world!:

;;;+;+;;+;+;
+;+;+;+;;+;;+;
;;+;;+;+;;+;
;;+;;+;+;;+;
+;;;;+;+;;+;
;;+;;+;+;+;;
;;;;;+;+;;
+;;;+;+;;;+;
+;;;;+;+;;+;
;+;+;;+;;;+;
;;+;;+;+;;+;
;;+;+;;+;;+;
+;+;;;;+;+;;
;+;+;+;

See also

Other languages operating on bits (implemented only):

External resources