Strelnokoff

From Esolang
Jump to: navigation, search

Strelnokoff is an esoteric programming language devised by Chris Pressey in 2001. It is a non-deterministic imperative programming language; each instruction unilaterally updates the global state of the program, but there is no guarantee as to the order in which instructions are executed.

Although the above description makes it sound untractable, it is "usable for computation" if one adopts a rigorous programming style of gating every single instruction with as many guards as is needed to prevent that instruction from being executed at the wrong time.

Etymology

The name Strelnokoff comes from the name of a fictional brand of vodka that appeared in an SCTV skit.

Syntax and semantics

Syntactically, Strelnokoff resembles BASIC. No line numbers are needed, however, as there is no guarantee as to the order that the program will be executed in anyway.

Each line contains an update statement of the form <variable-name> = <expression>.

The expression can consist of the common arithmetic expressions (addition, subtraction, multiplication, and division.) Division by zero evaluates to zero. Relational operations are available as well; these evaluate to one if the relation is true, and zero if it is not.

Primitive values can be specified either in decimal or as symbols in single quotes, which equate to ASCII values.

If the left operand of a multiplication evaluates to zero, the right operand is not evaluated, thereby guarding against any side effects.

There is also a unary operator, PRINT CHAR, which acts as an identity function, except that it also produces output as a side-effect.

Example program

The following is a "Hello, world!" program implemented in Strelnokoff.

REM HELLO WORLD IN STRELNOKOFF
REM CHRIS PRESSEY MARCH 24 2001
X = (X / X) * X + (X = 0) * (T =  0) * (PRINT CHAR 'H' - 'H' +  1)
X = (X / X) * X + (X = 0) * (T =  1) * (PRINT CHAR 'e' - 'e' +  2)
X = (X / X) * X + (X = 0) * (T =  2) * (PRINT CHAR 'l' - 'l' +  3)
X = (X / X) * X + (X = 0) * (T =  3) * (PRINT CHAR 'l' - 'l' +  4)
X = (X / X) * X + (X = 0) * (T =  4) * (PRINT CHAR 'o' - 'o' +  5)
X = (X / X) * X + (X = 0) * (T =  5) * (PRINT CHAR ',' - ',' +  6)
X = (X / X) * X + (X = 0) * (T =  6) * (PRINT CHAR ' ' - ' ' +  7)
X = (X / X) * X + (X = 0) * (T =  7) * (PRINT CHAR 'w' - 'w' +  8)
X = (X / X) * X + (X = 0) * (T =  8) * (PRINT CHAR 'o' - 'o' +  9)
X = (X / X) * X + (X = 0) * (T =  9) * (PRINT CHAR 'r' - 'r' + 10)
X = (X / X) * X + (X = 0) * (T = 10) * (PRINT CHAR 'l' - 'l' + 11)
X = (X / X) * X + (X = 0) * (T = 11) * (PRINT CHAR 'd' - 'd' + 12)
X = (X / X) * X + (X = 0) * (T = 12) * (PRINT CHAR '!' - '!' + 13)
X = (T = X) * 0 + (X > T) * X REM RESET FLAG
T = (X / X) * X + (X = 0) * T REM INCREMENT TICK

Computational class

Strelnokoff defines no limit on the values that its variables can take on. Also, there are at least 26 (single-letter) variables available. If we assume that variables can be manipulated arbitrarily by the judicious use of guards, it should be possible to simulate a Minsky machine with only two of the variables, which would mean that Strelnokoff is Turing-complete. However, any number of variables might be required to implement each guard properly, in which case we would have to ensure that there is no arbitrary limit on the number of available variable names. (The original language description, however, hints that arrays (possibly unbounded) were part of the original concept, but were left out of the original implementation.)

See also

External resources