WebAssembly in Go: Reasons for Design Decisions – Technical Discussion

From my experience with other languages ​​(C++, Rust), a WebAssembly module should be used like a library, a binary file exporting a set of functions.
Go however, treats WebAssembly as an executable. At runtime, functions can be registered in a global JS object. Functions are callable as long as the main method is running. Everyone including me uses the wait-on-channel-pattern to make the main method run forever. but why?

I searched the entire 500+ comment long initial issue for WebAssembly support (https://github.com/golang/go/issues/18892). It’s quite an interesting read, Nilens stepped up and gave it a try, and then let everyone participate in his journey! I salute you Nilens!

But nowhere can I find an explanation as to why Go does not comply with the WebAssembly export functionality.
I’m not saying it’s bad, in fact the dev experience is good enough, the interop between Go and JS is great.
I’m just wondering what were the reasons for that decision.
Does anyone have an idea? Maybe because of GC?


Leave a Comment