Brainfuck, short for Brainfuck Programming Language, is an esoteric, minimalistic programming language created by Urban Müller in 1993. Brainfuck consists of a simple set of eight commands, operating on an array of memory cells and a pointer. It is used primarily for educational purposes, programming puzzles, and exploring compiler and interpreter design. You can experiment with Brainfuck through interpreters available online or install command-line versions, such as via Brainfuck Interpreters on Esolangs.
Brainfuck exists to demonstrate how a Turing-complete language can be constructed with a minimal instruction set. Its design philosophy emphasizes simplicity and extreme minimalism, pushing the boundaries of what can be expressed in very limited syntax. The language is not intended for practical software development but serves as a testbed for understanding low-level computation, compiler theory, and code golfing.
Brainfuck: Memory and Pointer Basics
Programs in Brainfuck manipulate an array of memory cells using a pointer, starting at cell 0.
+++++ <!-- set cell 0 to 5 -->
> +++ <!-- move to cell 1 and set to 3 -->
< - <!-- move back to cell 0 and decrement -->The commands + and - increment and decrement the current cell, while > and < move the pointer. This forms the basis for all computation in Brainfuck.
Brainfuck: Loops
Loops are defined using [ to start and ] to end, executing until the current memory cell is zero.
[ <!-- start loop -->
- <!-- decrement current cell -->
> + <!-- increment next cell -->
< ] <!-- end loop -->Loops allow conditional repetition, and the bracket commands enable Turing-complete computation with only eight instructions.
Brainfuck: Input and Output
Brainfuck reads input using , and outputs characters with ..
, <!-- read a character into current cell -->
. <!-- output character stored in current cell -->Combining input/output with loops and memory manipulation allows programs to perform a variety of computational tasks, despite the minimal syntax.
Brainfuck: Sample Program
A simple program to print "A" to the output.
+++++++ <!-- set cell 0 to 7 -->
[ > +++++ < - ] <!-- loop to multiply value -->
> . <!-- print ASCII character -->This demonstrates the core principles of Brainfuck: using loops, cell arithmetic, and pointer movement to perform calculations and output results.
Brainfuck is used primarily for learning, experimentation, and recreational programming challenges. It provides a unique perspective on minimalism in programming language design and has inspired many derivative esolangs and code golf competitions.