Codex Mechanicus ∴ Архів Священних Даних ∴

adoptus / adoptus-wafer

WAFER — the Priest's Forging of FORTH

An extended inscription naming the priest's own implementation of FORTH 2012 — a JIT compiler that renders each Forth word as a separate WebAssembly module — as a sanctioned act of invention under the doctrine.

Канонічність
extended
Стан
draft
Themes
software, invention, forth, webassembly, forge
Востаннє змінено
2026-05-09
Мови
English

Premise

FORTH is named in this archive as the divine language of the machine in the present age. An adopted doctrine of that weight obliges its holder to do more than admire the tongue from a distance. The priest of this archive has therefore forged his own FORTH.

The forging is named WAFERWebAssembly Forth Engine in Rust — and is hosted at github.com/ok2/wafer.

This entry is extended, not adopted. There is no specific Mechanicus parallel for the act of building one’s own dialect of FORTH against the WebAssembly chassis; the doctrine that authorises the act is the Sanctity of Invention, under which any new work is sacred provided it is sourced, sealed, marked, and bound.

What is forged

WAFER is a FORTH 2012 compiler written in Rust. It does not interpret words and does not emit a single monolithic binary; instead, every defined word is rendered as its own WebAssembly module, and execution proceeds through an embedded wasmtime runtime that links the modules through a shared linear memory and a function table. The forging carries:

Against the GNU FORTH reference implementation (gforth) in release mode, WAFER renders Fibonacci, Factorial, GCD, NestedLoops, and Collatz at two- to ten-fold the rate.

Doctrinal standing

The Sanctity of Invention sets four conditions under which an inventive work is sacred rather than suspect. WAFER is filed against each:

Under these conditions WAFER is admitted to the archive as a small act of the Quest for Knowledge in its inventive face — not as a guilty deviation from the path of recovery, but as the priest’s contribution to the corpus.

Why WebAssembly is the proper chassis

The pairing is structural, not stylistic. WebAssembly is a stack machine with structured control flow and modules as the unit of compilation. FORTH is a stack language whose words are the unit of compilation and whose control flow is structured. The compilation of a FORTH word to a WASM module is therefore not a translation between unlike forms but a re-expression in a near-isomorphic register: subroutine threading becomes call and call_indirect; the data stack of FORTH becomes the operand stack of WebAssembly; the dictionary becomes the module table; shared linear memory replaces the unitary address space without altering the model. The two were designed, in different ages, around the same idea — and the priest’s forging makes the correspondence explicit.

Operative state

: FIB DUP 2 < IF DROP 1 ELSE DUP 1 - RECURSE SWAP 2 - RECURSE + THEN ;
: FIBS 0 DO I FIB . LOOP ;
12 FIBS CR    \ prints: 1 1 2 3 5 8 13 21 34 55 89 144

The above is consecrated FORTH; WAFER renders each colon-defined word into a WebAssembly module of its own, and the REPL prints the sequence as the standard requires.

What this serves

Cross-references

Пов'язані

Прийняття

Джерела