BinaryLanguage
Three registers, bit operations and one loop. Anything that is not a command prints itself.
None1, 2023 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
None1 made BinaryLanguage in 2023, after brainfuck and Befunge. There is no tape. Three registers A, B and C hold whole numbers of any size, and almost every command works on A with B beside it. There are and, or, xor and shifts by B bits. * rotates the three registers, which is the only way to reach C.
Read the story
A character that is not a command prints itself. So Hello World! is a Hello World and a quine at once.
The specification shows it is Turing complete with a table that turns each brainfuck command into BinaryLanguage. C holds the whole tape as one number, eight bits to a cell, and B holds the pointer as a count of bits.
The machine
| Command | Does |
|---|---|
+ - | Add 1 to A; subtract 1 unless A is 0 |
& ^ \| | A becomes A and, xor, or B |
< > | Shift A left or right by B bits |
~ | Swap A and B |
* | Rotate right, so A takes C, B takes A, C takes B |
( ) | Skip to the matching ) if A is 0; go back to the ( if not |
, . | Read a byte into A; print A as a character |
All three registers start at 0. , reads 0 at the end of the input.
Example
The truth machine builds 48 as 3 shifted left by 4 and keeps it in B.
The truth machine builds 48 as 3 shifted left by 4 and keeps it in B. It reads a character and xors it with 48, which leaves 0 or 1. On 1 the inner loop prints 1 forever. On 0 it skips both loops, xors the 48 back in and prints it.
Numbers come from shifts. Six + and a swap put 6 in B. Then 1 shifted left by 6 bits is 64, and one more is 65, the letter A.
A brainfuck + from the specification's table is (-)+<(*+**-). It clears A, shifts 1 left by the pointer and loops that many times, adding 1 to C on each pass. On the first cell that is once.
Patterns it teaches
- Turing tarpit: brainfuck fits in three numbers.
- Quine: any text without a command prints itself.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from BinaryLanguage
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: binarylanguage.
Command line
shib run binarylanguage -e 'Hello World!'shib manual binarylanguageSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/binarylanguage.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org