Echo
No variables. A value is a sound in flight, and memory is how long it takes to come back.
Charon25, 2021 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Charon25 made Echo in 2021. A program is a list of instructions that run one after the other, next to an audio source. The source sends sounds in up to four directions. Each sound carries a number from 0 to 255 and flies towards a wall, bounces and comes back. Every instruction is one unit of time, so a sound sent to a wall 3 units away returns 6 instructions later.
Read the story
When sounds come back, their numbers are added modulo 256. That sum is the only value an instruction can use. To keep a number, a program sends it out again. To add two numbers, it times them to come back at the same moment.
The machine
| Instruction | Does |
|---|---|
send d w n | Send n in the directions d, with a wall w units away |
redirect d w [1] | Send the sum, or 256 minus it, the same way |
print | Print the sum as a byte |
wall d w | Put up a wall that goes after one bounce |
condition t v n | Run or skip the next n by comparing the sum with v |
for r n | Run the next n instructions r times, then go on to them |
nop [n] | Wait n steps |
input d w | Send a byte of input |
exit | Halt |
Directions are the four low bits of d, so send 3 2 108 sends two sounds. A sound bounces off the first wall in its way, even a wall another sound put up. predirect and pcondition print the sum first.
A sound waits one step after it is sent, so with a wall 1 away it is back two instructions later. The Hello world sends two letters, then prints both as they arrive.
Example
The Hello world.
The Hello world. send 3 2 108 sends an l both ways to walls 2 away, and wall 1 1 puts a nearer wall in front of one of them. That one comes back two steps sooner, so the two ls print apart.
The multiplication keeps A, B and a running total in flight. Each round adds 255, which is -1 modulo 256, to A and adds B to the total. When A comes back as 0 it prints the total. With A as 5 and B as 13 it prints 65, an A.
The Fibonacci program prints 0, 1, 1, 2 and on up to 233, each as a byte.
Further
See also
Also in Strange time
Write your own in Run Convert a program from Echo
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: echo.
Command line
shib run echo -e 'send 2 4 1
nop
for 13 9
predirect 8 5
nop 5
redirect 1 8
nop 3
redirect 6 9
wall 4 3
nop 4
redirect 2 3
nop 5'shib manual echoSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/echo.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org