StupidStackLanguage
Twenty-six letters, one stack of numbers, and loops made of t and u.
Lebster, 2020 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 9 known programs · Test method
Run it
The idea
Lebster made StupidStackLanguage in 2020. Every letter of the alphabet is one command and nothing else counts, so a program looks like a string of random letters. Most commands do not pop. g adds the top two and pushes the sum on top of them, so programs keep cleaning up with b.
Read the story
This implementation follows the Python interpreter printed in the specification, quirks included.
The machine
| Letter | Does |
|---|---|
a b q y | Push 0, pop, duplicate, empty the stack |
i d v w | Add 1, -1, 5 or -5 to the top |
g c m p e | Push top plus, minus, times, divided by, mod the second |
n | Push 1 if the top two are equal, else 0 |
l r o s | Swap the top two, push the length, remove or swap by index |
f x | Print the top as a character or a number |
j h | Read a line, push its first character or its number |
k | Skip the next letter if the top is 0 |
t u | Loop: skip to u if the top is 0, go back to t if it is not |
z | Stop |
Numbers have no size limit, and p gives a float such as 3.5. On a top that is not 0, k falls through to the interpreter's invalid-character branch, which prints a message and stops.
Example
Hello World builds each letter from the one before it.
Hello World builds each letter from the one before it.
The factorial from the specification. q d keeps x and a counter below it, and the loop multiplies and counts down.
The calculator reads X, Y and Z and counts Z down to pick an operation. Z of 3 divides.
The Ackermann function, with A(2, 3) = 9.
Patterns it teaches
- Stack machines: every value lives on one stack and commands reach in by index.
- Turing completeness: unbounded numbers and a while loop are enough.
See also
Stack-based
Write your own in Run Convert a program from StupidStackLanguage
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: stupidstacklanguage.
Command line
shib run stupidstacklanguage -e 'jf' --input 'cat
'shib manual stupidstacklanguageSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/stupidstacklanguage.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org