Adds a parallel build of all three Lumbda implementations to WASM, a
single-page playground at www/playground/, and a verified test suite.
Tiers
- Python: Pyodide (CPython-in-WASM) hosting lumbda.py
- C: Emscripten build of c/ (tree-walker + bytecode VM; jit.c
stubbed, gc.c uses its existing no-Boehm fallback)
- Asm: hand-written asm/lumbda.wat — parallel impl to asm/lumbda.s.
Reader, eval (lambda/define/if/cond/let/and/or/quote/set!),
recursion across mutated top-level env, bump allocator with
memory.grow, 24 primitives. ~1200 lines of raw WAT.
SPA (wasm/app/, deployed to www/playground/)
- CodeMirror 6 editor (Scheme highlighting) on left, output on right
- Radios: 4 demos (Mandelbrot, Fib+Ack, Sieve, self-interp meta-eval)
x 4 tiers (Python | C | Asm | All three)
- All-three mode renders the three tier outputs side by side with
per-tier elapsed timing
Tests (38 verified assertions)
- 20 unit (Node): per-tier module loads, eval smoke
- 8 integration (Node): each demo on c+asm WASM byte-matches the
canonical native Python run
- 10 functional (Playwright headless Chromium): page mounts, every
demo runs on every tier, all-three renders
Makefile
- Root targets: wasm-build, wasm-test, wasm-test-fn, wasm-serve,
wasm-deploy, wasm-clean
- wasm/Makefile orchestrates the three tier builds; deploy copies
dist/ into www/playground/
Asm tier notes
- WAT linear symbol intern + linear env lookup is MOAD-0001 at scale;
documented in the asm/lumbda.wat header and in the SPA footer. The
demos hit ~30 globals so the linear walks are cheap enough.
- Bump allocator never frees (matches asm/lumbda.s heap discipline);
memory.grow expands by 1 MB chunks. Browser tab tears down at unload.
Toolchain (developer prerequisites)
- Emscripten 6.0.0 via emsdk at ~/git/emsdk
- wabt 1.0.36 at ~/git/wabt
- Playwright for functional tests (symlinked from ~/git/agnt)
79 lines
3.1 KiB
HTML
79 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Lumbda playground — Lisp in your browser, three tiers</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<script type="importmap">
|
|
{
|
|
"imports": {
|
|
"@codemirror/state": "https://esm.sh/*@codemirror/state@6.4.1",
|
|
"@codemirror/view": "https://esm.sh/*@codemirror/view@6.34.1",
|
|
"@codemirror/commands": "https://esm.sh/*@codemirror/commands@6.6.2",
|
|
"@codemirror/language": "https://esm.sh/*@codemirror/language@6.10.3",
|
|
"@codemirror/legacy-modes/mode/scheme": "https://esm.sh/*@codemirror/legacy-modes@6.4.1/mode/scheme",
|
|
"@codemirror/theme-one-dark": "https://esm.sh/*@codemirror/theme-one-dark@6.1.2",
|
|
"@lezer/highlight": "https://esm.sh/*@lezer/highlight@1.2.1",
|
|
"@lezer/common": "https://esm.sh/*@lezer/common@1.2.3",
|
|
"style-mod": "https://esm.sh/*style-mod@4.1.2",
|
|
"crelt": "https://esm.sh/*crelt@1.0.6",
|
|
"w3c-keyname": "https://esm.sh/*w3c-keyname@2.2.8"
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Lumbda <span class="sub">— Lisp/Scheme in your browser, three tiers in parallel</span></h1>
|
|
<p class="tag">
|
|
Same Lisp source. Three implementations compiled to WebAssembly:
|
|
<strong>Python</strong> (CPython via Pyodide hosting <code>lumbda.py</code>),
|
|
<strong>C</strong> (Emscripten build of the tree-walker + bytecode VM),
|
|
<strong>Asm</strong> (hand-written WebAssembly Text format — parallel to <code>asm/lumbda.s</code>).
|
|
</p>
|
|
</header>
|
|
|
|
<section class="controls">
|
|
<fieldset class="program">
|
|
<legend>demo program</legend>
|
|
<label><input type="radio" name="program" value="mandelbrot" checked> Mandelbrot</label>
|
|
<label><input type="radio" name="program" value="fib-ack"> Fib + Ackermann</label>
|
|
<label><input type="radio" name="program" value="sieve"> Sieve of Eratosthenes</label>
|
|
<label><input type="radio" name="program" value="self-interp"> Lisp-in-Lisp meta-eval</label>
|
|
</fieldset>
|
|
<fieldset class="tier">
|
|
<legend>tier</legend>
|
|
<label><input type="radio" name="tier" value="python"> Python (Pyodide)</label>
|
|
<label><input type="radio" name="tier" value="c" checked> C (emcc)</label>
|
|
<label><input type="radio" name="tier" value="asm"> Asm (WAT)</label>
|
|
<label><input type="radio" name="tier" value="all"> All three</label>
|
|
</fieldset>
|
|
<button id="run">Run</button>
|
|
<span id="status" class="status"></span>
|
|
</section>
|
|
|
|
<section class="panes">
|
|
<div class="pane code-pane">
|
|
<h2>code</h2>
|
|
<div id="editor"></div>
|
|
</div>
|
|
<div class="pane output-pane">
|
|
<h2>output</h2>
|
|
<div id="output"></div>
|
|
</div>
|
|
</section>
|
|
|
|
<footer>
|
|
<p>
|
|
<strong>Asm tier note:</strong> the WAT implementation ships a minimal Lisp
|
|
subset (special forms, arithmetic, list ops, recursion) — enough for the
|
|
four demos above. Symbol lookup is linear; would be MOAD-0001 at scale,
|
|
documented in <code>asm/lumbda.wat</code>. See
|
|
<a href="https://lumbda.com">lumbda.com</a>.
|
|
</p>
|
|
</footer>
|
|
|
|
<script type="module" src="app.js"></script>
|
|
</body>
|
|
</html>
|