esolang

Counterlang

Named counters, a goto by line number, and no way to ask a question.

2024 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 1A

The idea

Counterlang, from 2024, keeps its data in named counters. A line can add to a counter, take from it or reset it, print a number or a character, or jump to another line. That is all. There is no if, so a loop that should end has to jump to a line number that it keeps in a counter.

The machine

LineDoes
count aMake the counter a, at 0
a5 abAdd 5, or add the counter b; aa doubles a
a-5 a-Take 5 away; reset to 0
.5 ,65Print 5 as a number; print the character 65, A
!3 !aGo to line 3, or to the line a holds
:End the program

A # starts a comment. Lines count from 1. Running past the last line also ends the program.

Example

The two print lines.

The two print lines.

The counter lines add 1, take 2 and add 2, then double three times. That leaves a at 8, though the comment says 16.

Expected: 8

A loop that stops. The counter t starts at 7 and grows by 1 on every pass, so !t lands one line further down a table each time. Two entries jump back to the loop and the third ends the program.

Expected: 123

The specification's own loop counts up from 0 and never stops.

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Counterlang

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run counterlang -e '.1 #prints 1
,65 #prints A'
shib manual counterlang

Source

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

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

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