esolang

S.I.L.O.S

Superb Interpreted Language's Obviously Superior. Also known as SIL, the Simple Interpreted Language.

rjhunjhunwala · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 6 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

S.I.L.O.S is built for a nostalgic view of the past. One command per line, one letter per variable, a label on a line of its own and GOTO to reach it. There is no syntax checking at all. A line that is not a command is skipped, so plain text works as a comment.

Read the story

Each variable is a cell of one heap of 32-bit integers, named by its character. a is cell 97, and a longer name like count is just c. The same heap can be reached by number with set and get, which makes pointers and arrays possible.

The machine

CommandDoes
print text, printLine textPrint the rest of the line as typed, the second with a newline
printInt x, printChar nPrint a variable as a number, or a value as a character
x + n and - * / % ^ & : ! ? < >Change x in place, like x += n in C
x = n, x = get n, x = (a + 2) * bAssign a value, the cell at n, or an expression
set n mPut m in the cell at n
lblname, GOTO name, if n nameA label, a jump, and a jump when n is above 0
funcname, GOSUB name, returnFunctions without arguments
stack n m, stackPop n, queue n m, queuePop n32 stacks and 32 queues; a pop lands in m
readIO, loadLineA number into i, or a line of text into cells 256 on

The heap has 8192 cells unless the first line is a number. A second line def a b turns every a in the program into b before it runs. Expressions are worked out in floating point and cut to an integer, with ^ first and every operator read left to right, so 2^3^2 is 64. An error inside one command, such as a division by zero, skips that command and the program carries on.

On Try It Online the input comes as command line arguments. Each line of the input is one argument. The leverage command, which pulls in a standard library, is not built.

Example

The second program counts to five.
Expected: 1 2 3 4 5
Expected: 144
Expected: hello!

The second program counts to five. b is set to 6 minus a, and the loop goes on while it is above

  1. The last one reads a line into the heap and walks it with a pointer until it finds an empty cell.

Patterns it teaches

  • Counter machines: integer cells, arithmetic and a conditional jump are all a program needs.
  • Turing completeness: the heap has a fixed size, but the 32 queues grow without limit.

Try this

  1. Print the numbers 10 down to 1.
  2. Read a line and print it backwards.
  3. Hard: a function that prints the value of n in binary.

Further

Also in Turing tarpits

Write your own in Run Convert a program from S.I.L.O.S

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run silos -e 'print Hello, World!'
shib manual silos

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/silos.js

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

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