SpaghettiScript
Brainfuck without loops. To go round again, a function calls itself.
UltimateProGrammer, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
UltimateProGrammer made SpaghettiScript in 2020 as a joke, and the specification calls all code in it spaghetti code. It is a tape of numbers like brainfuck, with a fork that points at one cell, but there are no loops. Code lives in numbered functions, and the only way to repeat is for a function to call itself, or go to itself, and to stop when a test on the current cell says so.
Read the story
Calls come in two kinds. ---≡1 calls function 1 and comes back to the code after it. ===≡1 goes to function 1 and drops the rest of the current function. A test {o=0} in front of either lets it happen only when the cell is 0.
The machine
| Code | Does |
|---|---|
~ - | Add or take 1 from the cell |
⇢ ⇠ | Move the fork right or left; → and ← work too |
:O :OA | Print the cell as a number or as a character |
:o | Read a number into the cell |
[1 ... ] | Define function 1 |
---≡1 ===≡1 | Call function 1; go to it for good |
{o=0} | Do the next call only if the cell is 0 |
O ≡O | Hold the cell in memory; put the memory back |
The code outside the functions runs from the top, and every other character is a comment. Cells start at 0 and can go below it.
Example
The Hello World is twelve lines, one per character, with 1,085 tildes in all.
The Hello World is twelve lines, one per character, with 1,085 tildes in all. Each line counts a fresh cell up with 72 or 101 or 108 tildes and prints it, and every line after the first moves the fork on before it counts. Two characters on one cell need fewer, since i is 33 above H.
The Count Down program ends function 1 with a call to itself, and a call comes back, so it counts on past 0 and never stops. Written with goto it stops at 1, and the last goto lands in the empty function 2.
Patterns it teaches
- Turing tarpit: brainfuck's tape, with recursion where the loops were.
See also
Cell-based
Write your own in Run Convert a program from SpaghettiScript
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: spaghettiscript.
Command line
shib run spaghettiscript -e '[1:o:O] ---≡1' --input '42'shib manual spaghettiscriptSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/spaghettiscript.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org