esolang

Fish Code

Every line is a fish, < for a mouth and >< for a tail, and the program swims from line to line.

None1, 2023 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Nope.

The idea

None1 named Fish Code after the shape of its lines. Each one starts with < and ends with ><, and the commands are the body in between. The program starts on line 0 and runs it from left to right. A jump sends it to another line. A line that ends without a jump ends the program.

Read the story

There is one byte register and two byte stacks, and every sum wraps at 256. Two stacks are enough to hold a brainfuck tape, one for each side of the head, and that makes the language Turing complete.

The machine

CommandDoes
+ -Register up or down by 1
, .Read a byte into the register; print it
: ;Read a decimal number; print the register in decimal
? ! ~Push the register; pop into it; switch stacks
((x)) (((x)))Set the register to x; subtract x from it
(A) [A] {A}Jump to line A if the register is 0; if it is not; always

Example

The Nope.

The Nope. interpreter sets every character but the p, which is one more than the o.

A truth machine. Subtracting 208 is adding 48 when bytes wrap, so the register becomes the digit again. Line 3 jumps to itself and prints 1 forever.

Expected: 0

The reverse cat pushes a 0 to mark the bottom, pushes every byte up to the newline, then pops and prints until it meets the 0.

Expected: hsif

Further

Ideas it shows

Stack-based

Write your own in Run Convert a program from Fish Code

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: fish-code.

Command line

shib run fish-code -e '<((78)).((111)).+.((101)).((46)).><'
shib manual fish-code

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/fish-code.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org