esolang

Width

Only letters count, and each letter means the digit of how wide it is.

stestoltz · Turing complete: unknown · ●●● hard

Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: Hello, World!

The idea

Width sorts the 52 letters into ten classes by their printed width, from the thin i j l (0) to the wide W (9). Everything that is not a letter is thrown away, so a program can hide inside ordinary text. The interpreter is a Python 3 script.

Read the story

The digit decides what a letter does. Classes 2, 5 and 6 are the ternary digits 0, 1 and 2 of a command, so ww is command 22, print. A class 3 letter separates two commands.

The machine

DigitLettersDoes
0i j lLoop while the counter is not 0
1f r t IEnd a block
2 5 6c k s ..., A B E ..., w C D ...Command digits 0, 1, 2
3a b d e ...Separator
4F T ZA number, up to the same letter
7G O QA string, two letters per character, up to the same letter
8m MIf the top is true
9WElse

There are about a hundred commands on Python values for arithmetic, strings, a counter, a second stack called the backburner. A command that hits an empty stack quietly does nothing. Nothing is printed at the end; the top item becomes the exit code.

Example

FKF is 5 and FwF is 6; swA is command 021, multiply, and ww prints.
Expected: 30
Expected: 3 2 1

FKF is 5 and FwF is 6; swA is command 021, multiply, and ww prints. The last one sets the counter to 3 with ss, then loops; each round pushes the counter, prints it and counts down.

Patterns it teaches

  • Camouflage: punctuation, digits and spaces are ignored, so a program can be written as prose.
  • Encoding tricks: a letter's meaning is its shape.

Try this

  1. Read a number and print it doubled (command 1012).
  2. Print the numbers 5 to 1.
  3. Hard: write a Hello World that reads as an English sentence.

Further

Also in Golfing

Write your own in Run Convert a program from Width

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run width -e 'Acaww' --input '21
'
shib manual width

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/width.js

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