From Esolang
Jump to navigation Jump to search

Smalllang is a joke esoteric programming language invented by User:A created in order to fullfill User:Hanzlu's definition of a usable language, as it tries its best to make itself as unusable as possible.

"In my opinion a programming language needs four essential parts in order to be a usable language. I list them in the following order of importance: 1. Changing values 2. Output 3. Control flow 4. Moving in memory"


Smalllang has a tape that only has 2 binary cells. In order to increment a cell in memory, use the . instruction (1. changing values). If you increment a value, you can not decrement it back; it is always 1 and you can never change it anymore. In order to move right, use the > instruction (4. moving in memory). If you move right, you can not move back left, and if you reach the right end of the tape, you are not allowed to move right anymore.

Smalllang also has an output instruction, which is * (2. output). This outputs the bit to the console and then deletes that bit in the memory. Smalllang also has control flow, the ? instruction(3. control flow). It is a while loop (containing an if statement), and if the current cell is nonzero, it jumps back to the start of the program. Similar to the * instruction, it deletes the current cell before it switches the code execution.


Here is an interpreter for Smalllang by User:Hanzlu (modified by User:A to avoid the possibility of an Infinite loop by typing .?, and also prevents errors by checking them):

code = ""
l = len(code)
i = 0

memory = [0, 0]
ptr = 0

while i < l:
    c = code[i]
    if c == ".":
            memory[ptr] = 1
    elif c == ">":
        ptr = 1
    elif c == "*":
    elif c == "?":
            if memory[ptr]:
                i = -1

    i += 1