esolang

Wittgen

Two instructions, assign and retrieve, and a variable called Doing Now that holds the rest of the program.

2012 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: part 1:=hello} part 2:=world} greeting:=hello world!}

The idea

Wittgen dates from 2012. It asks how a brain that has nothing but associative memory could still reason one step after another, so it gives a program only the two things associative memory does. It can tie any text to any name, and it can fetch the text tied to a name. There are no numbers, no conditions and no loops. The specification says these two operations are enough to build a Turing machine.

The machine

A program is text made of assigns. name:=text} gives the variable name the text, and inside the text @name} is replaced by what that variable holds.

Running a program assigns all of its text to the variable Doing Now. Then the first assign is taken off the front of Doing Now and performed, again and again, until Doing Now holds no assign. An assign to Doing Now changes what runs next, which is how a program jumps and loops.

  • An assign replaces every retrieve in its text first. An assign nested in the text is kept as written, retrieves and all, so code can be stored and run later.
  • A retrieve of a variable that does not exist makes the whole assign do nothing.
  • Line breaks in the source are ignored.

Wittgen has no input and no output. This implementation shows the memory at the end, every variable but Doing Now as name:=text} on its own line, in the order they were first made.

Example

The example joins two variables into a third.

The example joins two variables into a third.

Without the first assign the retrieve of part 1 fails, and greeting is never made.

Expected: part 2:=world}

Arithmetic is a table of associations. @inc @n}} retrieves n first, so with n at 0 it reads the variable inc 0.

Expected: inc 0:=1} inc 1:=2} n:=2}

The second assign below replaces the rest of Doing Now with one nested assign, so z is never made.

Expected: x:=1} y:=2}

Patterns it teaches

Further

Also in Rewriting

Write your own in Run Convert a program from Wittgen

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run wittgen -e 'My variable:=hello world!}'
shib manual wittgen

Source

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

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

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