Draft:Instrumentalities

From Esolanging
Jump to navigationJump to search

Instrumentalities is an esoteric programming language by User:AnalysisOfVariance in 2026. It was made to game the Esolang Quality Rating System yet again.

Overview

Just like a typical computer, the memory is an array of words and two word-sized registers A and B, as well as a word-sized output port and a word-sized input port. Unlike a typical computer though, the program is stored separately from the main memory, making Instrumentalities a Harvard architecture CPU compared to a typical modern CPU's von Neumann architecture where code and data live in the same memory allowing self-modification.

The word size and length of the array of words are both unspecified.

On initialization, all memory cells and the registers are initialized to zero.

Command Description Pseudocode
~ Increments the A register. A++
: Sets the A register to the word at the address of the A register. A = mem[A]
; Sets the word at the address of the A register to the value of the B register. mem[A] = B
! Swaps the A and B registers. A, B = B, A
' Copies the A register to the B register. B = A
" Copies the B register to the A register. A = B
+ Adds the B register to the A register. This is wrapping. A += B
- Subtracts the B register from the A register. This is wrapping. A -= B
* Multiplies the A register by the B register. This is wrapping. A *= B
^ Raises A to the power of B, using modular exponentiation where the modulus is the maximum word size. 0 raised to 0 is defined as 1. A = pow(A, B)
@ Jumps backwards by the B register amount of instructions (wrapping) if the A register is zero. if (A == 0) { ip = (ip - B) mod code length }
` Jumps forwards by the B register amount of instructions (wrapping) if the A register is zero. if (A == 0) { ip = (ip + B) mod code length }
< Outputs the A register to a serial word output port. outw(A)
> Reads a word from the serial word input port into the A register. A = readw()

What the input and output ports do are implementation-defined. They can do anything, even nothing.

Computational class

If the word array is of bounded size, then Instrumentalities is a bounded-storage machine thus making it a finite-state automaton.

Examples

XKCD Random Number

This works only if the word output port outputs integers.

~~~~<

Infinite loop

A=16, B=2
~~'^^
================

Implementations

Lua

-- word size = 16 bits
-- memory size = 65536 words
function run(code)
    local memory = {}
    for i in 1,65536 do
        memory[i] = 0
    end
    local a = 0
    local b = 0
end

Python 3

# word size = unbounded (out of laziness)
# memory size = 65536 words

def run(code):
    memory = [0] * 65536
    a, b = (0, 0)
    i = 0
    while i < len(code):
        i += 1

if __name__ == '__main__':
    run(input())

Final EQRS score

Instrumentalities is completely original, scoring it a 60 for originality.

Its talk page has (will have) at least 5 comments, giving it no penalties.

Its computational class is (will be fully) proven, giving it a +10.

It has (will have) 3 implementations, giving it a +10.

It has (will have) more than 5 examples, giving it a +10.

This gives it a score range of 85 to 95, which allows it to compete with Nope.'s range of 80 to 95.

See also