esolang

WTFCode

Even adding one to a number is an instruction, and every value has to say what type it is.

Asicosilomu, 2023 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

Asicosilomu made WTFCode on 3 February 2023, with the goal of over-complicating the simplest of tasks. There are no operators. Arithmetic, comparison and logic are all instructions, and every argument comes as a datatype followed by a value. number 5 is a number, string "hi" is a string, and returnvalue (...) runs one instruction and takes its result. So adding one to x takes a line like var set returnvalue x (add returnvalue (var get x) number 1).

Read the story

Most instructions are not even there at the start. They live in modules that the program has to include first, so a Hello World is two lines. The interpreter is written in JavaScript, and some of the language reaches through to it.

The machine

InstructionDoes
var set datatype name valueSet a variable
var get nameIts value
if [...] ... escapeRun the lines if the instruction in brackets gives true
while [...] ... escapeRepeat them while it does
function NAME [TYPE NAME ...] ... escapeDefine a new instruction
return datatype valueLeave a function with a value
eq value valueCompare
include local/...Load a module

The modules give show for output (ostream), add sub mult div mod floor and chains of them (math), great less greateq lesseq (comparison), not and or (logic), concat upper lower string (string), arrays, random, throw and nop.

This implementation leaves out what needs JavaScript or a browser underneath. That is jseval, which runs a line of JavaScript, ecfjs, which calls a JavaScript function, the dialogs, DOM and property modules, and modules loaded from the network. The quine is built on jseval, so it does not run.

Example

A mode argument takes a bare word instead of a typed value.

A mode argument takes a bare word instead of a typed value. That is how the specification's own function gets a word like SHOVE.

Expected: SHOVE in ur mom

The function that multiplies by ten. Its result is a returnvalue like any other.

Expected: 690

A count from 1 to 5 needs three modules.

Expected: 1 2 3 4 5

The 99 Bottles of Beer is included too, 99 verses in 2,272 steps.

Patterns it teaches

Further

Also in Hostile

Write your own in Run Convert a program from WTFCode

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run wtfcode -e 'include local/ostream
show log string "Hello, World!"'
shib manual wtfcode

Source

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

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

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