Beatnik
Programs are English prose. Each word's Scrabble score is the instruction it stands for.
Cliff L. Biffle, 2001 · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Cliff L. Biffle made Beatnik around 2001. A program is a list of words. Add up each word's letters with Scrabble values and you get a number. That number is the command. 7 adds, 9 prints, 17 stops.
Read the story
So the hard part is not the logic. It is finding words with the right score that still read like a sentence. Most Beatnik programs end up as odd, dreamy text, which is where the name comes from.
The author says the published spec has an error and will not say where, so this implementation runs "Beatnik at face value" and takes the spec as written as correct. Values are small and there is one stack, so it is not Turing complete.
The machine
One stack of integers. Words are separated by whitespace; only letters count. Letter values: A E I L N O R S T U 1, D G 2, B C M P 3, F H V W Y 4, K 5, J X 8, Q Z 10.
| Score | Does |
|---|---|
| 5 | Push the next word's score |
| 6 | Pop and discard |
| 7 | Pop two, push their sum |
| 8 | Read a byte and push it (-1 at end) |
| 9 | Pop and print as a character |
| 10 | Pop two, push second minus first |
| 11 | Swap the top two |
| 12 | Duplicate the top |
| 13, 14 | Pop; if zero (13) or not zero (14), skip n words past the next word, whose score is n |
| 15, 16 | Pop; if zero (15) or not zero (16), go back n words from the next word |
| 17 | Stop |
Any other score does nothing. Popping an empty stack gives 0. A jump back past the start lands on the first word.
Example
Hello scores 8 and reads A.
Hello scores 8 and reads A. aunts scores 5, so it pushes the score of Around, which is 7. The second around scores 7 and adds. swim scores 9 and prints 65 + 7, the letter H.
Patterns it teaches
- Camouflage: the program looks like a strange poem.
- Stack machines: a tiny stack machine under the prose.
- Encoding tricks: an opcode is a sum of letter values.
- Every text runs: any English text is a Beatnik program.
Try this
- Find a word that scores 5 and one that scores 9, and write a program that prints
!(33). - Read a character and print it twice.
- Hard: print
Hiwith a sentence a person could say out loud.
Further
See also
Pseudonatural
Stack-based
Write your own in Run Convert a program from Beatnik
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: beatnik.
Command line
shib run beatnik -e 'Hello, aunts! Around, around, swim!' --input 'A'shib manual beatnikSource
- Module
langs/stack/ports.js- Interpreter
langs/stack/beatnik.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org