ReviewOS

home-lang/home

Build a web playground (compile to wasm in browser)

#12
Open glennmichael123 opened this 9 days ago ·
9 days ago

Context

The single highest-leverage demo for a new language is a "try it in your browser" playground. Rust did it (play.rust-lang.org), Zig has one, Bun shipped one, Roc has one. It does more for awareness than 10 docs pages.

The wasm backend (packages/codegen/src/wasm.zig, 360 LOC) is currently a stub. The minimum playable version of a playground only needs:

  • The compiler itself running in the browser (compile to wasm32-wasi or wasm32-unknown)
  • A small subset of stdlib that works in a browser sandbox (no fs, no syscalls)
  • An in-browser editor (Monaco / CodeMirror) with home syntax highlighting
  • A "Run" button that compiles + executes the user's code via the in-browser compiler

Proposal

Phase 1: compiler runs in browser

  • Build the Home compiler itself targeting wasm32-wasi
  • Stub out the parts that need a real OS (file watcher, package downloads, etc.)
  • Verify a minimal hello-world compiles + runs

Phase 2: playground site

  • Static site at try.home-lang.org (or wherever fits)
  • Monaco editor + syntax highlighting (reuse the VSCode extension's tmLanguage)
  • "Compile" button shows IR / errors / wasm output
  • "Run" button executes the user's wasm
  • Shareable URL via gist (like Rust's playground)

Phase 3: nice to have

  • Example dropdown (load any of the examples/*.home files)
  • "Show desugared" toggle for educational value
  • WASI imports for basic IO so user programs can print()

Why this matters

  • Single most viral demo possible for a programming language
  • Forces honest answers about what the compiler actually requires (file IO, threading, etc.)
  • Drives the wasm backend forward as a side effect
  • Lower the "try it" barrier from git clone + pantry install + zig build to "click a link"

References

  • play.rust-lang.org — gold standard
  • ziglang.org/learn/samples — simpler model

Sign in to comment on this issue.