Flux (Esolangist)
Befunge's playfield, with loops you can name and a way back to where you were.
Esolangist, 2025 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Esolangist made Flux in 2025, after Befunge. A pointer walks a grid of characters that wraps at every edge, and each character is a command on a stack of integers with no limit on their size. An empty stack answers 0. Among what Flux adds to Befunge are two kinds of jump. l and e mark the two ends of a while loop on the grid, and m marks a place that R can jump back to later.
Read the story
The specification's table says e jumps back to its l when the top of the stack is 0. Every loop in the specification needs the opposite, a jump back while the top is not 0, and that is what this implementation does.
The machine
| Char | Does |
|---|---|
> v < ^ | Point the pointer |
[ ] ( ) | Pop; on 0 turn left, right, up or down |
- \| | Mirrors for up and down, and for left and right |
? r | A random direction; a random number from 0 to 255 |
0 to 9 | Push a digit |
+ S * / % | Add, subtract, multiply, divide, modulo |
= ! | Equal; not |
~ : x $ { } c | Drop, duplicate, copy n, swap, rotate both ways, clear |
. , & ' | Print a number or a character; read a number or a character |
" | Push the codes of the characters up to the next " |
g p | Read or write a cell of the grid |
# £ | Skip the next cell, always or when the top is not 0 |
j | Jump to the cell (x, y) |
m R | Mark a place; return to the last mark |
l e | Skip the loop when the top is 0; go back to l when it is not |
@ | Halt |
Example
The two Hello worlds.
The two Hello worlds. The first pushes a 0 and the text backwards, then prints until the 0 is on top. The second goes left from the corner and wraps, so it reads the text backwards on its own.
The cat prints characters until it reads a null character. In this implementation the end of the input reads as 0 too.
The truth machine. On 0 the £ does not skip, the pointer turns down at the first v and prints 0. On 1 it takes the second v, and R sends it back to the m and down into a loop that prints 1 forever.
The XKCD random number never reaches the lines below it.
Patterns it teaches
- Two-dimensional control flow: with loops and returns laid out on the grid.
- Stack machines: every command works the stack.
- Self-modifying code:
pwrites into the grid it runs on.
See also
Two-dimensional languages
Stack-based
Write your own in Run Convert a program from Flux (Esolangist)
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: flux-esolangist.
Command line
shib run flux-esolangist -e '>'\''l:,'\''e@' --input 'Flux '