Benul
A program of BEL and NUL characters. Shown on a terminal, it beeps.
David.werecat, 2012 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
David.werecat made Benul in 2012. A program holds only two characters, BEL (7), which rings the terminal bell, and NUL (0), which shows nothing at all. The specification asks that every program make a pleasing sound when it is displayed. What counts is the length of each run of one character, and a run longer than five is cut into runs of five and a rest.
Read the story
The machine is one bit, the value, and a queue of bits. Input and output go a bit at a time, eight bits to a byte, highest bit first. The program starts again from the top when it reaches its end. The only way out is a 4 NUL that finds the value 0 and no 4 NUL after it.
The machine
| Run | NUL | BEL |
|---|---|---|
| 1 | Nothing | Nothing |
| 2 | Put the value at the back of the queue and take the front one | Read a bit |
| 3 | Flip the value | Write the value |
| 4 | If the value is 0, go on after the next 4 NUL, or end when there is none | Put a 0 at the back of the queue |
| 5 | Set the value to 0 | Set the value to 1 |
The value starts at 0 and the queue starts empty.
Example
A console line cannot hold a BEL, so the console runs the terminating program, four NULs.
A console line cannot hold a BEL, so the console runs the terminating program, four NULs. It ends at once and prints nothing, because the value is 0 and no 4 NUL follows.
The specification writes its programs as hex dumps. The cat reads a bit and writes it, and never ends.
07 07 00 07 07 07
The truth machine is 100 bytes. It flips the value to 1 so it passes its first 4 NUL, reads the eight bits of a character and keeps the last one in the queue. Then it writes 0011000, the first seven bits of the character 0, and the kept bit after them. On 0 its last 4 NUL has nothing after it and the run ends. On 1 it starts again from the top, jumps over the reading part and prints 1 forever.
Hello, world! is 526 bytes that set and write 104 bits one by one.
Further
Ideas it shows
See also
Queue-based
Write your own in Run Convert a program from Benul
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: benul.
Command line
shib run benul -e '