Minicode
A command, a variable, a value. Loops are a jump back to a line number.
Kirill Leonov, 2024 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Kirill Leonov wrote Minicode in January 2024, with an interpreter in Rust. Each line starts with a short command and a variable name. There are no quotes; a value is a number when it reads as one, a variable when one has that name, and plain text otherwise. There is no loop and no if. The ? command compares two values and jumps to a line number when the comparison holds, so a jump back is a loop and a jump ahead is a branch.
The machine
| Line | Does |
|---|---|
> a value | Assign a number, a copy of a variable, or text |
> b a i | Assign character i of the string in a |
p a | Print the value and a line break |
= a + b | Change a number by + - * or / |
? a ! b 4 | Go to line 4 if a differs from b; also = > < |
$> a | Set a to a line of input, asked before the run |
Lines count from 1, and a comparison needs two values of one type. The full language also reads and writes files, runs system commands and includes other files. This implementation leaves those five commands out, and the prompt text that $> can show.
Example
The loop counts a up to 5 and jumps back to line 3 until it gets there.
The loop counts a up to 5 and jumps back to line 3 until it gets there.
The "hello" program, line by line. Past the end of the string the character is empty, which is printed as an empty line and ends the loop.
Two branches jump over the lines between them, so only the last line prints.
Patterns it teaches
- Counter machines: named numbers, arithmetic and a conditional jump.
- Turing completeness: a goto on a comparison is all the control it needs.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Minicode
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: minicode.
Command line
shib run minicode -e '> a 0
> b Hello world
= a + 1
p b
? a ! 5 3'shib manual minicodeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/minicode.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org