Why I use WebAssembly

20 points by runxiyu


weberc2

I like the idea of WebAssembly, but I don’t see how it’s meaningfully better as an “engine of application state” than JavaScript except in certain niche cases. The article mentions “you already have a desktop app and you want to ship a web version” but I’m very skeptical that even that case is a good one for WASM–if you’re going to have to port everything that touches the platform API (e.g., the filesystem, the platform UI libraries, etc) to the web, are you really better off using WASM (which has to pass through a JavaScript shim to use the web APIs anyway) than rewriting in TypeScript or similar? Maybe the answer is “yes” if your application has a lot of client-side code that is not UI logic (for example, Figma or AutoCAD) but those seem to be pretty rare as far as I can tell.

Similarly, I’m curious about WASM as a container replacement, but I don’t buy the “if WASM existed in 2012 we wouldn’t have needed Docker” argument if only because WASM does not solve for packaging an entire system, which means it’s only useful for apps that can be packaged as a single WASM artifact and I don’t think that limited vision was going to be forceful enough to change the industry the way containers did (for those of us who were around back then, it was a huge shift to get people to think in terms of containers even with the promise that they could package their existing apps into container images–I can’t imagine the professionals of 2012 wrapping their heads around a new orchestration model that wouldn’t accommodate the apps they had to support at the time).

Even as a container replacement today, I’m not quite sure what it offers me. It seems like it offers a simpler sandboxing model, but one which imposes a larger runtime performance/efficiency cost than that of containers (someone please correct me if I’m being too charitable toward containers). I’ve heard claims that it also reduces the size of the artifacts, but container images can be pretty tiny–I’ve shipped 2MB images before. I’m really not sure why I would prefer WASM over containers, even as someone who prefers Go which seems like it should be an almost ideal language for WASM?