I/M Machine

From Esolang
Jump to navigation Jump to search

I/M Machine is a strange esoteric programming language inspired by InterpretMe. The strangest thing is that infinite programs are completely normal and accepted.

I/M Machine
Paradigm(s) imperative, OISC
Designed by User:TenBillionPlusOne
Appeared in 2025
Memory system Accumulator-based
Computational class total/Unknown
Reference implementation Unimplemented
Influenced by InterpretMe
File extension(s) .imm

Overview

The only memory I/M Machine uses is an accumulator, which is initially set to 1. The program consists of natural numbers of natural numbers separated by whitespace. All other instructions which include characters other than iImM are ignored.

The command described below is called until the program halts:

  • The first number of the program is removed;
  • [removed number - 1] is added to the accumulator;
  • If accumulator is equal to 0, the program halts.

It can be seen as one instruction, which takes one argument a and executes the following pseudocode:

x+=a; if(--x==0) halt;

So I/M Machine can be analyzed as OISC.

I/M Machine can also be analyzed as turing tarpit with two instructions:

  • I - Increment accumulator by 1.
  • M - Decrement accumulator. If it's equal to 0, halt.

Finiteness

Finite I/M Machine

Finite I/M Machine (FIMM) is official version of I/M machine. All programs have finite size in it, and all instructions after the last are 0s. It's total and unusable for programming.

Infinite I/M Machine

Infinite I/M Machine (IIMM) is full version of I/M Machine, which has infinite programs. It isn't official part of the esolang, but it can be implemented in the following ways:

  • Adding instruction |. It's NOP, but at the end of the program IP returns to it if it's in the program. Easy to implement, but it does support only programs with periodic part, so it doesn't fully exploit the power of IIMM.
  • Adding a mathematical function definition as comment. After the last instruction is executed, the program calculates next instructions using the function. Easy to read but hard to implement.
  • Instead of executing IMM file, a file written in the same language as an interpreter is executed. The interpreter calculates each instruction using the file and executes it.

Computational class

Finite I/M Machine is obviously total, but computational class of Infinite I/M Machine is unknown.

(That's why the language is listed as both Unusable for programming and Usability unknown, and both Total and Unknown computational class.)

Relationship to InterpretMe

I/M Machine is shortcut of InterpretMe Machine. It's atemlanguage of InterpretMe, which means that IMM program is list of user inputs given to InterpretMe program *. Accumulator represents the minimal amount of empty user inputs required to terminate, counting from now.

Example programs

Truth machine

? | 1

Replace ? with a number. If it's 0, accumulator will be set to 0 and the program will halt. If not, it will run forever (word "loop" isn't appropriate here), with accumulator at a constant value ?. Note that 1 (IM) is a NOP.