A new project called Goeteia is pushing the boundaries of web development by enabling a pure Scheme programming experience directly in the browser, compiling code to WebAssembly live. This innovative tool promises to bring the power and expressiveness of Scheme, a Lisp dialect, to the web platform with native-like performance.
What Happened
Goeteia, described as "a page that compiles itself," is a pure Scheme web programming tool that compiles Scheme code to WebAssembly (Wasm) in the browser. The entire compiler, a compact ~70 KB gzipped goeteia.wasm file, is loaded and cached, allowing recompilation to occur rapidly, in approximately 15 milliseconds. The project's own website serves as a live demonstration, with its 3D title (a WebGL particle cloud) and other elements rendered by Goeteia itself.
The core features of Goeteia highlight its sophisticated design and deep integration with modern WebAssembly capabilities:
- Self-hosting Compiler: The compiler is written in the Scheme subset it compiles. Its build process is self-hosted, ensuring byte-identical output upon recompilation, a fixpoint checked through CI.
- Native Wasm GC Objects: It utilizes native WebAssembly Garbage Collection (GC) objects. Fixnums are unboxed
i31refs, while pairs and records are GC structs.eq?operations are handled efficiently withref.eq, eliminating the need for a JavaScript shadow heap and requiring only minimal byte-stream imports from the host. - Hygienic Macros: Goeteia supports robust hygienic macros, including
syntax-rulesand proceduralsyntax-casewith fenders, nested ellipses, anddatum->syntax. These macros run in a compile-time interpreter, ensuring hygiene through renaming. - Real Closures and Tail Calls: Functions leverage typed references with fast per-arity entries. Variadic procedures and
applyare optimized, and every tail call is areturn_call, enabling constant stack usage even for deeply recursive loops (e.g., a 100M-iteration loop completes in ~150ms without stack overflow). - The Numeric Tower: It implements Scheme's full numeric tower, with fixnums promoting to bignums on overflow, flonums with contagion, and exact rationals and complex numbers. Float literals are encoded to IEEE-754 by pure Scheme, ensuring byte-identical output across hosts.
call/cc&dynamic-wind: Escape continuations are implemented using the WebAssembly exception-handling proposal, providing O(1) capture and efficient winding/unwinding of winders.- Reactive Web Stack: A built-in reactive web stack offers
(web sx)templates over fine-grained(web reactive)signals, an(web html)renderer, and a(web js)FFI for direct interaction with the host environment. - Libraries: R6RS-style
(library ...)files support(import (math utils))resolution, with unused code pruning for efficient bundling.
Goeteia-compiled modules are designed to run on any engine supporting Wasm GC and tail calls, including Node.js 22+, current versions of Chrome, Firefox, and Safari, and runtimes like wasmtime.
Developers can get started by cloning the GitHub repository, running tests, rebuilding the compiler, and then compiling and executing Scheme code, as demonstrated in the quick start guide:
$ git clone https://github.com/guenchi/Goeteia
$ cd Goeteia
$ ./run-tests.sh # every test, both compiler stages
$ ./build-self.sh # rebuild the compiler with itself
$ echo '(define (fact n) (if (zero? n) 1 (* n (fact (- n 1))))) (fact 20)' > fact.ss
$ node rt/compile.mjs goeteia.wasm fact.ss fact.wasm
$ node rt/run.mjs fact.wasm
2432902008176640000
## Why It Matters
Goeteia represents a significant step forward for several aspects of web development and programming language ecosystems:
- Expanded Language Choice for WebAssembly: By bringing Scheme with its powerful features—like hygienic macros, first-class continuations, and a robust numeric tower—directly to WebAssembly, Goeteia demonstrates the growing viability of using non-JavaScript languages for client-side web development. This offers developers alternatives for building complex logic with different paradigms.
- Performance and Efficiency: The direct use of native Wasm GC objects,
i31refs, andref.eqfor equality checks bypasses the performance overhead often associated with JavaScript interop or custom shadow heaps. Combined with true tail call optimization, this promises highly efficient execution, especially for compute-intensive or recursive tasks. - Advanced Language Features on the Web: Scheme's advanced features, particularly hygienic macros, offer powerful metaprogramming capabilities that can significantly improve code modularity, reduce boilerplate, and enable domain-specific languages (DSLs) directly within web applications. This is a game-changer for developers looking for more expressive tools than typically found in mainstream web frameworks.
- Developer Experience: The self-hosting, in-browser compilation model is not just a technical feat; it creates a rapid feedback loop for development. The ability to edit code and see changes recompiled and rendered in milliseconds, without complex build toolchains, could drastically improve developer productivity for certain types of applications.
- Maturity of WebAssembly Features: Goeteia's reliance on WebAssembly's GC and exception-handling proposals underscores the increasing maturity and capabilities of Wasm itself. As these proposals stabilize and gain wider adoption, they unlock new possibilities for language runtimes and complex applications on the web.
What To Watch
As Goeteia continues to evolve, several key areas will be crucial to observe:
- Community Adoption: The long-term success of Goeteia will depend on its ability to attract a community of Scheme and Lisp developers, as well as new enthusiasts, willing to explore this novel approach to web development. Growth in libraries and tooling built on top of the reactive web stack will be vital.
- Browser and Runtime Support: While Goeteia targets current major browser versions and Node.js 22+, the WebAssembly GC and tail call proposals are still relatively new. Ongoing stability and consistent performance across different runtimes will be essential for enterprise adoption.
- Real-world Applications: Watching for the emergence of larger, more complex applications built with Goeteia will provide valuable insights into its scalability, maintainability, and suitability for production environments.
- Interoperability: While the
(web js)FFI exists, the ease and efficiency of integrating with existing JavaScript libraries and ecosystems will be a practical consideration for many developers transitioning to or experimenting with Goeteia.
Goeteia offers a compelling vision for a more diverse and powerful web development landscape, proving that the browser can indeed host a full-fledged, high-performance Scheme environment capable of self-compilation and advanced reactive UI. It's an exciting development for functional programming enthusiasts and those looking to push the boundaries of what's possible with WebAssembly.