Braille
Programs are written in Unicode braille. Each symbol is a byte, and its left column of dots says what to do.
Brian McPherson, 2014 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Brian McPherson made Braille in 2014, loosely after the Little Man Computer, a model computer from 1965 for teaching. A braille cell has eight dots in two columns of four. Read as bits, the left column is one hexadecimal digit and the right column another, so every symbol from ⠀ to ⣿ is a byte.
Read the story
The high digit is the action and the low digit, V, is its argument. The program is loaded onto a tape, and the same tape is the memory, so code and data are the same symbols. The data pointer starts just after the program; a shared cell just before it works as the accumulator.
The machine
| Action | Does |
|---|---|
| 0 | End |
1 2 | Add or subtract the cell V after the data pointer to or from the shared cell |
3 4 | Copy the shared cell there, or from there |
5 6 | Move the data pointer 2^V forward or back |
7 8 | Move the instruction pointer V+1 forward or V+2 back |
9 A | The same, if the shared cell is 0 |
B C | The same, if the shared cell is above 0 |
D E | Read a byte into the cell, or print it |
| F | Put a random byte in the cell |
Dots 1, 2, 3 and 7 make the action, from the top; dots 4, 5, 6 and 8 make V. So ⡆ is action E with V 0, print, and ⠆ is action 6 with V 0, step back one. Cells are bytes that wrap. The C interpreter that Try It Online runs prints bytes as they are.
Example
In the first program ⠆ steps the data pointer back onto the last symbol, ⡆ prints it and ⠀ ends.
In the first program ⠆ steps the data pointer back onto the last symbol, ⡆ prints it and ⠀ ends. That last symbol, ⠌, is never run; it is the byte 41 in hexadecimal, A. The second program does the same in a loop. The symbols after its ⠀ are the letters, last one first, and each round steps back, loads a symbol into the shared cell and prints it. When it loads the ⠀ itself, the jump for 0 lands on the shared cell, which now holds 0, the action that ends the program.
Patterns it teaches
- Self-modifying code: action 3 can write over any symbol of the program.
- Code as data: text to print sits in the program as symbols.
- Encoding tricks: two columns of dots read as two hex digits.
See also
Self-modifying
Write your own in Run Convert a program from Braille
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: braille.
Command line
shib run braille -e '⠆⡆⠀⠌'shib manual brailleSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/braille.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org