esolang

HashedPoem

Any words make a program. Only the hash of each word counts, and there are seven of them.

None1, 2024 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: A

The idea

None1 made HashedPoem in 2024. A program is a list of words, and each word stands only for its hash, a number from 0 to 6. The hash adds up the letter codes times powers of 256 and takes the rest after dividing by 7. Everything that is not a letter is left out, so or, with, can and *#?_ all hash to 0. Words with the same hash do the same thing, which means a program can be written as nonsense, as a poem or as anything in between.

Read the story

The hashes read as assembly. The first word picks one of seven instructions and the next words give its numbers. A number is written in base 6. Each word that hashes to 1 to 6 is a digit one lower, and a word that hashes to 0 ends the number.

The machine

HashInstructionDoes
0ADD a bCell a becomes a plus b
1SUB a bCell a becomes a minus b
2MUL a bCell a becomes a times b
3IO w aPrint cell a as a character if word w hashes even, read one into it if odd
4REF aCell a becomes the cell at the absolute value of a
5LABEL nMark a place
6JMP a nJump to label n if cell a is not 0

The tape holds unbounded integers. Cell 0 starts at 1 and every other cell at 0, so 1 is the only constant there is.

Example

Seven lines of nonsense that print A.

Seven lines of nonsense that print A. The first line hashes to 0 2 0 0, which is ADD 1 0. Three ADD 1 1 double the 1 to 8, MUL 1 1 squares it to 64, one more ADD 1 0 makes 65, and thanks to it or is IO 0 1, which prints it.

The truth machine in its meaningless form. It is thirteen instructions. It builds 48 in cell 1, reads a character into cell 0, keeps a copy in cell 2 and subtracts 48. Then it prints the copy and jumps back as long as cell 0 is not 0, so a 1 prints forever and a 0 prints once.

Expected: 0

The specification also writes the same truth machine as a short poem about cows and bees. All three forms hash to the same 44 digits. The specification's own listing of it says IO 1 2 near the end, but the words hash to IO 0 2, which prints, and only that makes it a truth machine.

Patterns it teaches

  • Camouflage: the meaning hides in a hash, so any text can carry it.
  • Encoding tricks: numbers in base 6 with a word as the terminator.
  • Counter machines: the specification shows it Turing complete by compiling a two register Minsky machine into it.

Further

Pseudonatural

Cell-based

Write your own in Run Convert a program from HashedPoem

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run hashedpoem -e 'is is is is is is is or'
shib manual hashedpoem

Source

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

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

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