esolang

Caps

Every statement in capitals and ended by STOP, data in typed blocks, and one loop that can only ask whether two things are equal.

2025 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hi

The idea

Caps is from 2025 and is meant to be hard to write in. There are no variable names. Data sits in a block, a list that holds one type, and a statement can only reach the current block. To carry a value into a new block you load it into a memory that outlives blocks, build the new block and unload the memory into it. That is also the only way to mix types in one block.

Read the story

Instructions are data too. They live in a block of their own type, can be joined into longer ones, and run with RUN or with LOOPDEF, the only conditional, which repeats while the first two elements of the block are equal. The specification counts the result as a Turing tarpit.

The machine

StatementDoes
BUILD BLOCK n STOPStart an empty block of type n
ENTRY d STOPAdd d to the block, if it fits the type
LOAD &i STOPCopy element i to the end of the memory
UNLOAD STOP UNLOAD +A STOPMove the last element of memory, or all of it, into the block
RUN &i STOP LOOPDEF &i STOPRun an instruction once, or while &0 equals &1
INCREMENT &i STOPAdd 1 to a number, step a character on, flip a boolean
BUILD IO STOP CONNECT &i path STOPMake an IO object and link it to a file
IO_PUSH &d &i STOP IO_PULL &i STOP IO_READ &i STOPWrite element d to it; read it; add what was read to a block of characters
NOTE text STOPA comment

The six types are 0 numbers, 1 characters, 2 booleans @T @F, 3 modifiers @N @J, 4 instructions written @I"LOAD &0 STOP" and 5 IO objects. A modifier acts the moment it is loaded and then vanishes. @N negates the number before it and @J joins the two before it. Numbers join as text, so 5 and 78.3 make 578.3, and characters join into a string. Printing means pushing to an IO object linked to /dev/stdout. Files live for one run, and /dev/stdin reads the input.

Example

A character block gets the IO object first, then the letters, each pushed out after it is entered.

A character block gets the IO object first, then the letters, each pushed out after it is entered.

The join and negation, printed. Number blocks do not take negative numbers, so -10 has to be made in memory, from a 10 and an @N out of a block of modifiers.

Expected: 578.3
Expected: -10

The loop is 105 statements and prints x three times. It joins 23 instructions into one with 22 @J and runs it with LOOPDEF while two zeros sit in front. Each pass prints an x, adds 1 to a counter, and rebuilds the block with the counter and the 3 in front, where an inner LOOPDEF compares them, and then once more with the zeros in front. When the counter reaches 3 the inner loop runs a second joined instruction, which loads an extra 1 into memory, so the next block starts with 1 and 0 and both loops end. It takes 181 steps, and with 5 in place of the 3 it prints five.

Patterns it teaches

  • Turing tarpit: one equality loop and a counter that is moved by hand.
  • Code as data: instructions sit in a block and are joined like strings.
  • Hostile design: no names, and every value is moved through memory.

Further

Cell-based

Write your own in Run Convert a program from Caps

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run caps program.txt

The program is long; save it as program.txt first.

shib manual caps

Source

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

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

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