Ash
Brainfuck on bits, where every cell starts as a coin toss but the one under the pointer.
Hakerh400, 2025 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Hakerh400 made Ash in 2025. The tape holds bits and runs both ways, and at the start every bit is random. Only the cell under the pointer is known; it holds 1. So a program has to make its own sure ground before it can keep anything. The basic trick is [~], which writes random bits for as long as the cell is 1 and so always ends on a 0.
Read the story
Input bits come with a 1 before each one and 0s after the last, so a program can see where the input ends. Output is plain bits.
The machine
| Command | Does |
|---|---|
< > | Move the pointer |
~ | Write a random bit |
, | Read a bit |
. | Print the bit as 0 or 1 |
[ ... ] | Repeat while the bit is 1 |
name := code | Put code in place of name in every later line |
The input 1011 is read as 1 1, 1 0, 1 1, 1 1 and then 0 for ever. In this implementation the random bits come from a fixed sequence, so a run replays.
Example
The cat reads a flag, and while it is 1 reads a bit, prints it and reads the next flag.
The cat reads a flag, and while it is 1 reads a bit, prints it and reads the next flag.
[~] makes a sure 0 beside the sure 1, and the two can be printed in any order.
The specification's examples start with 16 lines of definitions, and the last one, init, prepares the memory. With them the bit inverter is one line.
After the same definitions the reverser, 0 R R in [R in R in] and L L [R out L L L], turns 1011 into 1101. Run with 200 different random sequences, the cat, the inverter and the reverser gave the same bits every time.
Patterns it teaches
- Turing tarpit: six commands on single bits.
- Nondeterminism: programs that are sure of their result on a random tape.
Further
See also
Probabilistic
Write your own in Run Convert a program from Ash
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ash.
Command line
shib run ash -e 'l1 := <<[<<~[>>>0<<0]>>]>
r1 := <<[>>~[<0>>0]<<]>
l2 := <<[L'\''~[R'\'' >0 L'\'' 0]R'\'']>
r2 := <<[R'\''~[<<<0 R'\'' 0]L'\'']>
rand := ~
init := >0>
L'\'' := <<<<
R'\'' := >>>>
L := l2 L'\''
R := r2 R'\''
0 := [~]
1 := r1
flip := l2 [<<0>>0] r1 L'\'' <[>]> R
in := ,
out := .
init
in [in out in]' --input '1011'shib manual ashSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ash.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org