esolang

Sophie

One accumulator. A program may set it to a constant and ask what it holds, and nothing more.

Oshaboy, 2021 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 7 known programs · Test method

Run it

Expected: Hello, World!

The idea

Oshaboy made Sophie in 2021, because finite state automata are underappreciated. The specification says the name is Hebrew for finite. There is one accumulator and no arithmetic on it, so no program can count past the constants written in its source.

Read the story

That makes every Sophie program a finite state machine. The state is the value the accumulator holds when a loop starts over, and a big chain of conditions picks what to do in each state. It also means halting can be decided. Run the program until it halts or comes back to the top of a loop with a value it already had there.

The machine

CommandDoes
#c #$nLoad the character c or the number n
@c{...}{...}Run the first block if the accumulator holds c, else the second
@$n{...}{...}The same for the number n
[...]Loop until * breaks out
. ,Print the accumulator as a number or a character
: ;Read a number or a character
&Halt

The second block of @ may be left out. A block with no condition before it never runs, so {like this} is a comment. The end of the input reads as 0, which a cat program needs to stop.

Example

The character right after # is the constant, whatever it is, so #, loads a comma and # a space.

The character right after # is the constant, whatever it is, so #, loads a comma and # a space.

Expected: cat

The xor reads two numbers. Each of the four paths through the conditions prints its own answer.

Expected: 1
Expected: 0

Further

Also in Turing tarpits

Write your own in Run Convert a program from Sophie

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: sophie.

Command line

shib run sophie -e ';@1{[,]}{,&}' --input '0'
shib manual sophie

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/sophie.js

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

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