Link Search Menu Expand Document

The Brainfuck Textbook 🧠

A long-form guide to programming in Brainfuck


This book is still in progress. The project is looking for contributors. If you are interesting in collaborating, please email andreye@uw.edu.

Everyone who comes across Brainfuck finds the name lewd or somewhat entertaining; those that learn it find it warranted. BrainFuck is an estoeric language created by Urban Müller in 1993. The language has the smallest possible compiler of any Turing-complete language; Müller was able to write a 240-byte compiler, but others have been able to write even smaller compilers in the low 100s bytes. While Brainfuck possesses theoretical computational completeness, first-time encounters will make abundantly clear that trying to write anything that would be trivial in almost any higher-level language is exceedingly nontrivial in Brainfuck.


Why Learn Brainfuck?

To fuck your brain.

Let’s be real, computer programmers are pretty starved of intimacy. You need this.

To show off at nerd parties.

BrainFuck is a pretty good party trick to show off at nerd parties. Why greet people with “Hey there!” when you could say ++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>++.>+.++++++++++++++++++++.<<++.>>-----.------------.---.+++++++++++++.-------------.<<+.? Why apologize when you accidentally spill a drink on someone’s expensive shirt when you could say ++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>+++.<++.>>.+++++.-----.<<.>>++++++++++++++++.------------.-------.+++++++++++++++++++.<<.>>-----.-.<<.>>++.+++++.---.--.-.++++.--------------.?

To think critically about the nature of computation.

Higher-level languages allow us to abstract computation in a way closer to human syntactic and semantic systems. This is, of course, extraordinarily helpful for feasible development of complex programs. However, programming in Brainfuck forces humans to understand the low-level nature of computation more closely - for us to truly understand the semantics of raw computation. Don Knuth once noted (as a twist on the popular aphorism) that to truly understand something, one must teach a computer to do it. Translating concepts that come naturally - either to our complex minds or in higher-level languages - into Brainfuck forces us to examine our epistemological assumptions and biases, and makes us better programmers and thinkers.


This Book

This book is, to our knowledge, the first open-source project dedicated towards a long-form exploration of the Brainfuck language. While the syntax of Brainfuck is exceptionally simple (or perhaps because of it) to learn, the logic is exceptionally difficult. The goal of this textbook is to dive deep into algorithms, patterns, tricks, and strategies to thinking in the logic of Brainfuck. Additionally, this textbook will discuss approaches to manipulating and understanding Brainfuck code in relation to other languages, like generating Brainfuck code in another language.

Table of Contents.

ChapterDescription
Chapter 0Title. Read about the many different options to get set up with your Brainfuck environment.
Chapter 1Brainfuck Syntax and Function. Learn the eight operators and build a simple ‘parrot’ program.
Chapter 2Numeric Manipulation.
Chapter 3Text Manipulation.
Chapter 4Elementary Logic.
Chapter 5…?
Chapter 6…?
Chapter xBrainfuck Quines.