ETA
Eight commands, named after the eight commonest letters in English. Numbers are written in base 7, using those same letters.
Mike Taylor, 1999 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Mike Taylor made ETA in 1999. Its commands are E, T, A, O, I, N, S and H, the most frequent letters in English text. Every other character is a comment. So almost any English sentence is an ETA program, and usually a broken one.
Read the story
The name has a second joke. Eta is the seventh letter of the Greek alphabet, and ETA counts in base 7. A number starts with N, then uses seven of the letters as digits, and ends with E. NTHIE is 1, 0, 4 in base 7, which is 53, the character 5.
There is no add, no compare and no loop. You get subtract, a combined divide-and-remainder, a conditional jump to an instruction number, and one stack command, H, that can both copy and move items.
The machine
One stack of integers. Instructions are numbered from 1, and a whole N...E number counts as one.
| Letter | Does |
|---|---|
N | Read base-7 digits H=0 T=1 A=2 O=3 I=4 N=5 S=6 up to E, push the number |
E | Pop b, then a; push floor(b/a), then b mod a |
S | Pop b, then a; push b - a |
O | Pop and print as a character |
I | Push one input byte (-1 at end of input) |
A | Push this instruction's own number |
T | Pop addr, then cond; if cond is not 0, jump to instruction addr (0 halts) |
H | Pop n; n > 0 moves the nth item below the top to the top, n <= 0 copies the -nth item (0 is dup) |
Popping an empty stack gives 0. Letters count in either case. Dividing by zero stops the program.
Example
NTHIE pushes 53, the character 5.
NTHIE pushes 53, the character 5. The loop starts at instruction 2: NHE H duplicates, O prints. NTE NTE H S swaps a 1 under the value and subtracts, so the character goes down by one. NHE H NSSE NTE H S computes the character minus 48, which is 0 only after 1. NAE T jumps back to instruction 2 while that is not 0. The specification's own Hello world prints its text backwards with one wrong digit, so it is not used.
Patterns it teaches
- Stack machines: one stack, and H does the work of dup, swap and pick.
- Encoding tricks: numbers in base 7, spelled with the command letters.
- Camouflage: any English text is ETA, so code can hide in prose.
Try this
- Print
Hiwith twoN...Enumbers and twoOs. - Write a cat that copies its input until it reads -1.
- Hard: write an English sentence that is also a working ETA program that prints one character.
Further
See also
Stack-based
Write your own in Run Convert a program from ETA
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: eta.
Command line
shib run eta -e 'IO' --input 'a'shib manual etaSource
- Module
langs/stack/ports.js- Interpreter
langs/stack/eta.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org