This article is part of a series on brainfuck, a weird programming language:
- Brainfuck part 1: what is it?
- Brainfuck part 2: an interpreter in JavaScript
- Brainfuck part 3: a brainfuck → JavaScript transpiler
Brainfuck is an esoteric programming language using only eight characters ><+-.,[]
.
It has no pratical use but it’s fun and challenges the mind.
Design
The language has only eight commands: the eight characters. Any other character is ignored and can be use for commenting.
The programming model is simple: you have a 30,000 cells data array and a pointer to the current cell.
You can modify the value of this cell, print it (ASCII output) or replace it with the value of the keyboard input.
>
move the data pointer forward
<
move the data pointer backward
+
increments (+1) the current cell
-
decrements (-1) the current cell
.
outputs the current cell as an ASCII character
,
reads one character from the input and writes it in the current cell
[
makes the program jump to the instruction after the matching ]
if the current cell’s value is 0.
]
makes the program jump to the instruction after the matching [
if the current cell’s value is not 0.
Having only these commands is the ‘’fuck’’ part of brainfuck.