HeadlinesBriefing favicon HeadlinesBriefing.com

POP-2 Language Design for Uxn Virtual Machine

Hacker News •
×

A new implementation of the POP-2 programming language targets the Uxn virtual machine, featuring an ALGOL-like syntax with a deeply concatenative evaluation model. Unlike traditional languages, POP-2 uses an explicit operand stack where assignments like `123 -> foo` push values before consumption. The compiler is remarkably compact, under 800 lines and fitting within 2.5kb of memory.

The language structure resembles Pascal with keyword-led statements terminated by semicolons. Functions return multiple values by leaving them on the stack for subsequent operations. Control flow includes `if/then/elseif/else/close` blocks that push values onto the stack, and loops utilize explicit `goto` statements. Variables are declared in `vars` blocks with configurable byte lengths.

I/O operations target the Varvara system using port numbers (e.g., `0x48 => 23` outputs "H" to console port 0x17/0x18). Arrays support pointer arithmetic via the `#` prefix and curly braces for memory dereferencing. A complete string printing function demonstrates the stack-based approach to iteration and output. The implementation is written in Uxntal and hosted at intercatlang.incoming.