/brainfuck

A virtual Brainfuck machine in Go

Primary LanguageGo

Brainfuck

Brainfuck is an esoteric programming language created in 1993 by Urban Müller.

Notable for its extreme minimalism, the language consists of only eight simple commands and an instruction pointer. While it is fully Turing complete, it is not intended for practical use, but to challenge and amuse programmers. Brainfuck simply requires one to break commands into microscopic steps.

The language's name is a reference to the slang term brainfuck, which refers to things so complicated or unusual that they exceed the limits of one's understanding.

The Instructions

Brainfuck is tiny. It consists of eight different instructions. These instructions can be used to manipulate the state of the Brainfuck machine:

  • > - Increment the data pointer by 1.
  • < - Decrement the data pointer by 1.
  • + - Increment the value in the current cell (the cell the data pointer is pointing to).
  • - - Decrement the value in the current cell.
  • . - Take the integer in the current cell, treat it as an ASCII char and print it on the output stream.
  • , - Read a character from the input stream, convert it to an integer and save it to the current cell.
  • [ - This always needs to come with a matching ]. If the current cell contains a zero, set the instruction pointer to the index of the instruction after the matching ].
  • ] - If the current cell does not contain a zero, set the instruction pointer to the index of the instruction after the matching [.

That’s all of it, the complete Brainfuck language.