esolang

HakerScript

A program starts with two commands, install and uninstall. Everything else is a package you install first, and every variable is named like an IP address.

Provitia, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello world!

The idea

Provitia made HakerScript in 2021 for an esolang jam, meant to be confusing and readable at the same time. A program starts with nothing but install and uninstall. Printing needs install "show", a jump needs install "goto", and uninstall can remove any command, install itself included. Variables are set with bruteforce and read back with ping, and their names must be IPv4 addresses such as 127.0.0.1.

Read the story

The only branch is check. Unless its value is 0 it jumps to twice its own line number, so programs pad themselves with empty lines to land on the right one.

In the specification an install takes 4 seconds and a bruteforce 1 to 5. Both also print a log, but the specification does not give its text. This implementation leaves out the logs and the pauses, and nothing else.

The machine

PackageDoes
show vPrint a value, with no line break
newlinePrint a line break
input inputstrRead a line as an integer or as a string
bruteforce a.b.c.d vSet a variable
ping a.b.c.dGive a variable's value
sum vAdd v to the last value bruteforce set
negate nGive -n
goto nJump to line n
check vUnless v is 0, jump to twice this line's number
silenceTurn the logs off or on
turtlejamWrite numbers as turtle repeated, and 0 as noturtle

An argument can be another command, whose result it takes. A jump outside the program ends it.

Example

The truth machine.
Expected: -2

The truth machine. On 1, check on line 9 jumps to line 18, which goes back to the loop on line 11 that prints 1 forever. On 0 it falls through to goto 9999, which is past the end, so it stops after the prompt.

Expected: Enter either 0 or 1:

The 99 bottles of beer counts down the same way. Line 10 checks the count and jumps to line 20 while it is not 0. To take one down it bruteforces -1 into 255.255.255.255, so that sum adds -1 to the count.

Patterns it teaches

  • Hostile design: every command has to be installed before use, and the only branch doubles the line number.

Further

Also in Hostile

Write your own in Run Convert a program from HakerScript

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run hakerscript -e 'install "show"
show "Hello world!"'
shib manual hakerscript

Source

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

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

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