Back to browse
GitHub Repository

A Wasm to Go translator

209 starsGo

A WASM to Go Translator

by ncruces·Feb 26, 2026·7 points·1 comment

AI Analysis

●●●BangerWizardryBig Brain

Wasm-to-Go compiler enabling pure-Go SQLite driver across 20 platforms.

Strengths
  • Genuinely novel approach: translates Wasm binaries to Go instead of interpreting at runtime
  • Handles SQLite (600k LoC) successfully with test parity across 20 platforms—real proof of concept
  • Mixed performance profile (better on boundary-heavy code, parity on compute-heavy) is honest and instructive
Weaknesses
  • Incomplete Wasm spec coverage (no SIMD, export aliasing, or table/global imports) limits generality
  • Generated code intentionally unreadable (goto/stack-to-register) and spectest compliance incomplete
Target Audience

Go developers embedding WASM modules, SQLite maintainers, systems programmers

Similar To

wazero · wasmtime

Post Description

I've spent the past couple of weeks building a Wasm-to-Go translator.

It supports a subset of Wasm useful enough to translate SQLite into 600k LoC (~20 MiB) of Go code. It already passes all of my Go SQLite driver's tests across the 20 platforms I support.

Performance compared to wazero is a bit of a mixed bag: code that frequently crosses the Go-Wasm boundary improves, but code that spends most of its time in "Wasm land" doesn't.

There's probably room for improvement (I'd love to hear your ideas), but this is also a testament to how good the wazero AOT compiler actually is.

You can get a feel for the generated code by looking into https://github.com/ncruces/wasm2go/tree/main/testdata

I should eventually spend some time ensuring the translator passes the spectest, though I suspect that'll be far less fun than building the translator itself was.

Similar Projects