BrainF++

The ridiculously minimalist programming language

BrainF++ is like programming with your hands tied behind your back... and blindfolded... while riding a unicycle. With only 8 commands, it's somehow Turing complete and can theoretically run anything your fancy modern languages can. It's the programming equivalent of making a gourmet meal with just a spoon.

Tired of dealing with time constraints on algorithms in programming contests? How about memory constraints? Sign up for the contest here and join the select group of people who like making things unnecessarily complicated.

Original BrainF: only eight commands

>
Move pointer right
<
Move pointer left
+
Increment cell value
-
Decrement cell value
.
Output cell value as ASCII or Unicode
,
Input ASCII or Unicode to cell
[
Jump forward if cell is zero
]
Jump back if cell is non-zero

The ++ part: functions!

Function system
BrainF++ supports the advanced, modern and forward-looking concept of functions for code organization and reuse.

Function declaration

Functions are declared with curly braces. The syntax is {mn code here} where the two-letter function name immediately follows the opening brace.

{ab+++.}// Function named "ab"

Main function

Execution always begins in the main function {mn}. Code outside of any function is ignored and does not execute.

{mn+++.}// Main function - this runs

Return values

Use the semicolon ; command to return a value from a function. The current cell value is returned and replaces the cell value at the call site.

{ab++++++;}// Returns 6

Function calls

To call a function, use parentheses with the two-letter function name: (ab). The current cell value is passed as input, and the return value replaces the current cell.

{ab+++;}
{mn++(ab).}// Calls function "ab"

Global cells

Global cells are cells which are accessible to the left of the starting cell. They are static across all function calls.

The ab function decreases the global variable and returns 1 if it is positive, the mn function goes to the next cell as long as this value is positive. Overall, the program moves right the inputted number of times.

{ab[-]<-[>+;]}
{mn<.>+[>(ab)]}

How to write "Hello World!"

Your first masterpiece
This program outputs "Hello World!" and will make you question your life choices
++++++++++[>+++++++>++++++++++>+++<<<-]
>++.>+.+++++++..+++.>++.
<<+++++++++++++++.>.+++.------.--------.>+.>+.

Line by line explanations:

++++++++++ - Count to 10 (off to a great start!)

[>+++++++>++++++++++>+++<<<-] - The magic loop that sets up our ASCII values: 70 in cell 2, 100 in cell 3, and 30 in cell 4

>++. - Move to cell 2, add 2, output 72 = 'H'

>+. - Move to cell 3, add 1, output 101='e'

+++++++. - Add 7, output 108='l'

. - Output another 'l'

+++. - Add 3, output 111='o' (almost there!)

>++. - Move to cell 4, add 2, output 32=' '

...and the rest is just more ASCII arithmetic suffering 🌞

Live BrainF++ playground

Playground
Write and run BrainF++ code. Warning: may cause existential crisis

Interpreter options

Run your code to see output here...

Join the madness: BrainF++ contest

Think you've mastered the art of programming with 8 commands? Put your skills to the test in our monthly BrainF++ coding contests! Compete against fellow masochists... err, enthusiasts... to solve algorithmic challenges using nothing but the magnificent eight. Warning: side effects may include questioning your career choices and an inexplicable urge to write everything in BrainF++.

The origin story

Back in 1993, Urban Müller looked at programming languages and thought "You know what? These have way too many features." So he created BrainF++, a language so minimal it makes assembly look verbose. It's proof that you can make programmers cry with just 8 characters. Despite being designed as a challenge to create the smallest possible compiler, it accidentally became a rite of passage for masochistic programmers everywhere.