Skip to content
A minimalist esolang designed to be painful to use but better because the original makes too much sense
Branch: master
Clone or download
Pull request Compare This branch is 29 commits ahead, 5 commits behind DJMcMayhem:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

To undertand Pain-Flak you need to know brain-flak, so read this nice tutorial written by DJMcMayham and edited by me


Pain-Flak is an "Turing-tarpit", e.g. a language which can, in theory compute anything, but in reality is very inconvenient and painful to use. It was heavily inspired by Brainf**k, the original turing-tarpit.

To get started with Pain-Flak, download the project from here, and run ruby brain_flak.rb inputs. Additionally, you can try it online! (Online intrepreter provided thanks to @DennisMitchell)


Pain-Flak has two stacks, known as 'left' and 'right'. The active stack starts at left. If an empty stack is popped, it will return 0. That's it. No other variables. When the program starts, each command line argument is pushed on to the active stack.

The only valid characters in a Brain-Flak program are )(><][}{, and they must always be balanced. There are two types of functions: Nilads and Monads. A nilad is a function that takes 0 arguments. Here are all of the nilads:

  • )( Evaluates to one.
  • ][ Evaluates to the height of the current stack.
  • }{ Pop the active stack. Evaluates to the popped value.
  • >< Toggle the active stack. Evaluates to zero.

These are concatenated together when they are evaluated. So if we had a '3' on top of the active stack, this snippet:


would evaluate to 1 + 1 + active.pop() which would evaluate to 5. Note: this would not actually evaluate to 5 but more on that later.

The monads take one argument, a chunk of Brain-Flak code. Here are all of the monads:

  • )n( Push 'n' on the active stack.
  • ]n[ Evaluates to negative 'n'
  • }foo{ While zero is not on the top of the stack, do foo.
  • >foo< Execute foo, but evaluate it as 0.

These functions will also return the value inside of them

The {} will evaluate to the sum of all runs. So if we had '3' and '4' on the top of the stack:


would evaluate as 7.

When the program is done executing, each value left on the active stack is printed, with a newline between. Values on the other stack are ignored.

That's it. That's the whole language.

Back to the pain

The code is reversed (with bracket swap so ))(( would be ))(( again not (())) and concatenated to the end of the original source. Then it is run.


Code: )))(((}{

Gets transformed into: )))(((}{}{)))(((

And when run returns:




I am going to be adding a decent amount of new features and removing some, in brain-flak you can use comments but now you cannot in pain-flak. More control flow will be coming

Hard Hello World (provided by @Dennis also):


You can’t perform that action at this time.