Reducing a language to a minimum

Brainfuck was designed by Urban Müller in 1993, in the setting of Amiga computers and the Aminet software archive. Sebastian Morr's study of computer languages notes that Müller was then a Swiss physics student and that the first compiler was only 296 bytes. The project pushed language syntax and implementation size towards a minimum, seeking to test design boundaries rather than provide a convenient tool for writing business applications.

In the second 1993 distribution preserved on Aminet, the compiler had shrunk to 240 bytes, accompanied by an interpreter, assembly and C source code, and examples. In his update notes, Müller thanked Chris Schneider for suggestions on reducing the compiler's size. This acknowledgement makes the collaboration behind the minimal implementation concrete: the language had an identifiable designer, while miniaturization of its compiler also incorporated another programmer's suggestions.

References: [1] [3]

Eight instructions and a data tape

The language uses a pointer to select a cell in an array. Plus and minus change the cell's value; greater-than and less-than move the pointer. A period outputs a character and a comma reads one. Square brackets form a loop whose continuation depends on whether the current cell is zero. The language supplies no separate readable variable names or multiplication keyword; complex operations must be assembled from these steps.

The distribution notes initialize the pointer and array to zero and state that ordinary non-instruction characters are ignored. Reading a program requires distinguishing movement to another cell from changing the number in a cell. Each uses only one symbol, but they change different states. Nor does a loop inherently repeat a fixed number of times: programmers must arrange the counter cell, decrement operations and the pointer's return position themselves to make it end where intended.

References: [1] [2]

How a greeting program constructs a letter

The original distribution's hello.b begins with “>+++++++++[<++++++++>-]<.”. Reading from an all-zero state, the pointer first moves right and places 9 in the second cell. Inside the brackets, each iteration returns to the first cell and adds 8, then moves back to the second and subtracts 1. After nine iterations, the second cell is zero and the first has accumulated 72. Finally, the pointer moves left and outputs the ASCII character H.

The value 72 is not written into the program as a numeric constant; it is constructed by adding eight nine times. The program then changes the same cell's value to produce the remaining characters in sequence. Tracking just the first two cells shows how a loop shortens a string of consecutive plus signs. It also reveals the cost of reading: the reader has to retain each cell's value and the pointer's position mentally or on paper. A greeting is difficult to recognize immediately from the symbol string alone.

References: [2]

What the compiler and interpreter do

The second version's smaller compiler came at a cost: it required Amiga OS 2.0, changed the unit of operation to a byte and generated executable files of a fixed 65,536 bytes. A tiny compiler does not mean every program it generates is also only a few hundred bytes. The documentation also warned that it did not check bracket matching. The ability to submit text for compilation therefore did not guarantee a working executable.

The C interpreter offers another view. Its switch statement dispatches symbols to pointer movements, addition and subtraction, and input/output operations. On encountering an opening bracket, it scans for the corresponding closing bracket and then repeatedly interprets the loop body. The source also includes errors for unmatched brackets and out-of-bounds pointers, and an optional extra argument enables the hash character to print some array values. Such debugging facilities belong to a particular implementation; the hash character should not be counted as a ninth core instruction.

References: [1] [2]

Computational power and implementation limits

Daniel Temkin's study emphasizes that every Brainfuck symbol has a simple meaning, but combinations quickly obscure a program's purpose. Even setting an integer requires choices by the programmer. Morr also cautions that discussion of Turing completeness must disregard actual memory limits. Abstract computational power neither means a finite machine can handle inputs of any size nor implies that every mathematical problem can be solved.

Implementations are not entirely consistent. Morr lists differences in array boundaries, cell widths and end-of-input handling; the original C source itself includes pointer-range checks. A program's success in one interpreter therefore does not prove it will work in every variant. Comparisons of results should specify memory configuration and input/output conventions as well as the meanings of the eight symbols, avoiding confusion between implementation choices and a uniform standard.

References: [2] [3] [5]

A later small-scale experiment in compiler technology

The minimalist language later entered compiler research. In his 2023 bachelor's thesis at Ludwig Maximilian University of Munich, Jacob Schwaiger used Brainfuck to build an introductory project for the Multi-Level Intermediate Representation framework, MLIR. He mapped basic instructions to operations and represented loop bodies as regions containing internal operations, then used several levels of transformation to produce LLVM intermediate representation.

The thesis aimed to demonstrate compilation using a language small enough to be manageable yet capable of covering several framework features. Its conclusion explicitly described the implementation as a preliminary compiler and left further optimizations for future work. The example shows Brainfuck's continuing value: an early challenge in program size could become a controlled subject for studying semantics, representation and transformation. The aim had shifted from shrinking an Amiga compiler in 1993 to demonstrating a modern compilation process.

References: [4]