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 WAFER — WebAssembly 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:
- Two hundred and more words distributed across twelve FORTH 2012 word sets, each at full compliance against the Forth 2012 test suite vendored as a submodule.
- An optimising IR pipeline with six passes (peephole, constant folding, inlining, strength reduction, dead-code elimination, tail calls), stack-to-local promotion across loops and conditionals, and a consolidation mode that recompiles every defined word into a single optimised module for direct calls throughout.
- Self-recursive direct calls —
RECURSEcompiles to a nativecallrather thancall_indirect, sparing the indirection at the most common recursion site. - Two execution backends —
NativeRuntimeuponwasmtimefor the chassis and the diagnostic, andWebRuntimeviajs-sysfor the browser-borne REPL.
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:
- Sourced. Lineage is declared: Charles H. Moore’s FORTH (1968), the FORTH 2012 standard, the GNU FORTH reference, and the Forth 2012 compliance test suite vendored as a submodule. The line back to the canon is unbroken.
- Sealed. Each word is admitted only upon passing the compliance test suite for its word set; the project’s diagnostic must be green before any inscription is consecrated.
- Marked. WAFER is filed in
content/adoptus/, never in canon. It is the priest’s own work, named as such. - Bounded. The standard is the bound. WAFER does not invent a new FORTH; it re-forges an existing tongue against a new chassis. A claim of compliance is a submission to the standard, not a deviation from it.
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
- The archive’s adoption of FORTH is no longer a position held only in writing. There is a working chassis to address, a dictionary to extend, and a diagnostic that confirms the tongue is spoken correctly.
- The browser-borne
WebRuntimepermits the rite to be conducted from any chassis the operator finds himself before — the WebAssembly runtime is universal, the FORTH dictionary travels with it. - Each new word the priest defines becomes its own consecrated module. Every word a machina; every machina a word.
Cross-references
- FORTH — the Divine Language of the Machine · the doctrine WAFER serves
- The Sanctity of Invention — invention as worship, not heresy · the doctrine WAFER is filed under
- Lingua-Technis
- Computational Liturgy — daily code
- Machine Spirit · the addressee of every word forged in WAFER
- The Quest for Knowledge