esolang

Brainflub

One accumulator, an output nobody sees until the end, and a command that makes any program a quine.

Snorepion · Turing complete: no · ●○○ easy · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: ++--:|

The idea

Snorepion made Brainflub around an accumulator and a private output. + and - move the accumulator, = adds its character to the private output, and nothing reaches the screen until | ends the program or . shows the output early. The specification says its documentation is written as a joke, but the language works.

Read the story

: throws the collected text away, prints the program's own source and stops. So a program that reaches : with no . before it is a quine. There are no loops and no jumps, so a program runs once from left to right. The space is a command too. It reads a line of input, and * copies that line into the output.

The machine

CommandDoes
+ -Add or take 1 from the accumulator
~Reset the accumulator to 0
dDouble it (only in the Python and C compilers)
=Add the accumulator's character to the private output
.Show the private output now
,Clear the private output
\|Show the private output and end
:Drop the private output, print the program and end
spaceRead a line of input
*Add the last line read to the private output

Example

The first is a quine.
Expected: fefe
Expected: Hi

The first is a quine. Only the : counts; the rest is there to be printed. The second is a double cat. It reads one line with the space and adds it twice. The third counts up to 72 for H and 33 more for i.

The Hello, world program takes 361 characters. Its variant that ends in .: instead of | prints Hello, world! and then its own source.

Patterns it teaches

  • Quine: one command does it, by reading the source.

Further

Also in Jokes

Write your own in Run Convert a program from Brainflub

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: brainflub.

Command line

shib run brainflub -e ' *|' --input 'cat'
shib manual brainflub

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/brainflub.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org