logoalt Hacker News

neomantratoday at 12:42 PM0 repliesview on HN

I've been playing with Golang and WASM lately; hands-on WASM was new to me.

I found that many dependencies in the ecosystem (especially older ones) do not support GOARCH=wasm nor GOOS=js / GOOS=wasip1. I've had to fork and add support and then do go.mod replace directives. It can get messy.

Golang build tags make it awesome to have different implementations for different systems.

In the browser, it's all single threaded, so goroutines starve each other. I had to put in "breaths" for interactivity.

There's no local filesystem, so you have to figure out other solutions. Some dependencies use the filesystem as an implementation detail or try to shell out. The program will build, but will error at runtime.

That said, it is pretty sweet when it works. You can make WASM games with ebitengine [1] and it emits instructions for a WebGPU renderer; very efficient and many interactivity concerns are handled for you. The NTCharts demo page [2] combines Zig (Ghostty), WASM+Typescript+GLSL (Ghostty Web), and Golang (booba/ntcharts). The WASM size for the demos there is ~5MB each.

My goal is to make tools for terminal remoting and simplify bringing TUIs to the browser. [1] https://ebitengine.org

[2] https://nimblemarkets.github.io/ntcharts/demos/heatpicture-p... press 't' for kitty graphics