Running rontolisp WASM in plain HTML + JavaScript

The two programs below were written in Lisp and compiled ahead of time to WebAssembly (WASI Preview 1) with rontolisp. This page provides a tiny WASI shim in JavaScript, instantiates each .wasm module, runs its _start, and shows whatever it printed to stdout. No server, no framework. All the Lisp sources and the shim live in examples/browser/wasm-browser.

Want to write Lisp and compile it to WASM in the browser, then run the result here? See the playground and its compile & run page (these links work on the published site).

1. Run a self-contained program

hello.wasm computes Fibonacci numbers and some exact rational arithmetic, printing the result. Click to run it in your browser. Source: hello.lisp.

(output appears here)

2. Pass input from the page into the program

greet.wasm reads one line from stdin. The shim feeds the text below as stdin, so this shows how to send data from the browser into a WASM program. Source: greet.lisp.

(output appears here)

3. Real randomness from the host

dice.wasm rolls five dice with random. On WASI Preview 1 random draws real entropy from the host's random_get (the shim backs it with crypto.getRandomValues), so click Roll again and the result changes every time -- it is not a fixed pseudo-random sequence. Source: dice.lisp.

(output appears here)