esolang

Pxem

The program is the file name. The file itself can stay empty.

nk., 2008 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 18 known programs · Test method

Run it

Expected: Hello, world!

The idea

nk. (then known as ぬこ) played code golf on anarchy golf, where GolfScript let some problems be solved with one-byte files. Pxem was the answer to that, a language for zero-byte files, published in 2008. The code is written in the name of the file, and the content is only read when the name asks for it.

Read the story

A command is a dot and one character. Everything else in the name is text, and the text before a command is pushed onto the stack just before the command runs, first character on top. So hello world.pxe is a Hello World. Its .p pops and prints the whole stack, and the xe after it is pushed and never printed.

The machine

One stack of integers, a one-value register, and the file's content.

CodeDoes
.p .o .nPrint the whole stack as text, one character, one number
.i ._Read a byte (-1 at the end), read a number
.c .s .vDuplicate, drop, reverse the stack
.f .ePush the content as text; run the content as code
.w .x .y .z … .aLoop while not 0, while less, while greater, while not equal
.t .mPop into the register, push it back
.+ .- .! .$ .%Add; larger minus smaller; multiply; larger divided by smaller; remainder
.r .dA random number below the top; end

The first line of a program is the file name and the rest is the content.

Example

.z pops two letters and loops while they differ.
Expected: dlrow olleh
Expected: hijj
Expected: cat

.z pops two letters and loops while they differ. It eats a b, c d, e f, f g and stops at g g, which leaves hijj. Numbers are made the same way from pairs of characters, 12.- being 50 minus 49, or 1. The echo program uses that to add 1 to each byte it reads, so the loop ends when -1 comes back as 0.

The FizzBuzz is a file name of 213 characters, and prints 1 to 100.

Further

Ideas it shows

Probabilistic

Nondeterministic

Write your own in Run Convert a program from Pxem

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run pxem -e '42.pxe'
shib manual pxem

Source

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

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

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