Di Wang 中文

Running MoonBit in the Browser

Jun 11, 2026

This post was generated by AI.

This site can now embed live MoonBit code. The editors below are powered by moonpad-monaco: the MoonBit compiler runs as WebAssembly inside a web worker, so everything — type checking, diagnostics, even the language server behind autocompletion — happens locally in your browser. Nothing is sent to any server.

Let us start with the inevitable:

Press Run and the program is compiled to JavaScript and executed on the spot. You can also edit the code first — try changing the greeting, or introducing a type error to see the diagnostics.

Here is a slightly more interesting one, with pattern matching and a loop:

I plan to use these playgrounds in course materials, where readers can poke at typing rules and operational semantics with executable examples instead of static listings.