Playground & WebAssembly
The playground compiles and runs Marrow programs entirely in your browser. Nothing is sent to a server: the site is static, and the compiler itself runs as WebAssembly.
How it works
Section titled “How it works”The Marrow compiler is written in Marrow, so it can compile itself to WebAssembly. The playground loads that build in a Web Worker and runs three steps:
marrow --emit-ilcompiles your program to QBE’s intermediate language, without callingqbeor a C toolchain.- A small translator (
il2wasm.mjs) turns that IL into a WebAssembly module. - A second worker instantiates the module. Its only import is the raw system call, which
runtime.mjsemulates: standard streams, an in-memory file system,mmap, clocks, random numbers andexit.
Programs can use the whole standard library that does not need threads or the network. Sockets, fork, exec and threads answer ENOSYS.
A run is stopped after 20 seconds, so an endless loop does not freeze the page. Stop ends it earlier.
Sharing
Section titled “Sharing”Share copies a link that holds the program itself in the URL fragment, so it is never sent anywhere either.
Doing it yourself
Section titled “Doing it yourself”marrow --emit-il --nostdlib --target x86_64-linux main.mw main.ssanode tools/wasm/build.mjs build/marrow out/ # compiler.wasm, std.json, translator, runtimenode tests/wasm.mjs # the runnable test programs, in WebAssembly--emit-il stops after code generation and writes the IL to the output path.