Shove
A 2D language that never overwrites code. It shoves strings in, and the rest of the row slides out of the way.
ais523, 2008 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 2 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
ais523 made Shove in 2008 and forgot to tell anyone until 2013. It is a two-dimensional language, like Befunge, with a stack of strings instead of numbers.
Read the story
Strings come off the playfield between quotes. The odd part is how they go back. Popping a string does not write over cells. It inserts the string, and the whole ray of cells from that point on is pushed along to make room. If the instruction pointer sits on that ray, it gets pushed too.
So the program grows as it runs. A loop can lengthen itself each time round, which is how the counter prints one more star per line.
The machine
A playfield of characters and a stack of strings. The pointer starts top left, moving right. The program halts when the pointer leaves the playfield.
| Char | Does |
|---|---|
' " | Push the text up to the matching quote; the other kind of quote nests inside |
< v > ^ | Turn |
A V ( ) | Pop a string and shove it in, starting at the cell above, below, left or right, laid out in the current direction |
S | Print the top string without popping |
n | Print a newline |
space ! | Do nothing |
Popping an empty stack shoves an empty string, which changes nothing.
Example
The first row pushes ,olleH and V shoves it into the row below, just under itself.
The first row pushes ,olleH and V shoves it into the row below, just under itself. The rest of that row, "<, slides seven cells right, so < lands exactly under the v. The pointer turns down, then left, and reads the second row backwards as one string: Hello, World!. S prints it and the pointer walks off the left edge.
Patterns it teaches
- Stack machines: a stack of whole strings, not numbers.
- Two-dimensional control flow: arrows steer the pointer.
- Self-modifying code: every pop inserts code and moves the rest.
Try this
- Print
hiand a newline in one row. - Change the example so it greets
Everyoneinstead ofWorld. Which row must change? - Hard: trace the counter,
>"*"V" ")vover^nS"" <, for two rounds.
Further
See also
Self-modifying
Two-dimensional languages
Write your own in Run Convert a program from Shove
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: shove.
Command line
shib run shove -e ''\''say "hi"'\''Sn'shib manual shoveSource
- Module
langs/stack/ports.js- Interpreter
langs/stack/shove.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org