by Rochus · 6y ago · 0 comments
Even if true, it doesn't help much if you have to marshall through JS for nearly every call.
> You can write an entire front end web application if you want
One of the core benefit propositions was the possibility to write browser applications in any language, not just JS.
Outside of a few hobbyists, nobody is writing entire web applications in wasm. We already have great frameworks for dealing with UI/DOM stuff.
"Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications."
So did they mean only GUI-less client applications?
EDIT: also e.g. this source https://developer.mozilla.org/en-US/docs/WebAssembly/Concept... makes it clear that porting e.g. C++ GUI applications is an intended feature, not just a silly idea of some hobbyists.
My favorite example is Rapier http://rapier.rs/, check out the 3D demos. It blows every JS physics engine out of the water, and it’s using Conrod, a native gui library which has a webgl backend.
Ammo js: http://kripken.github.io/ammo.js/examples/webgl_demo/ammo.ht...
Ammo wasm: http://kripken.github.io/ammo.js/examples/webgl_demo/ammo.wa...
They can be faster, but it is still insane how fast JS interpreters have become. So for smaller application it might be ok to stay in JS land.
If your particular front end code is dominated by many calls to the DOM, then WASM may be a net performance loss currently, yes.
In cases where you are doing something computationally heavy then periodically updating the dom with results, then WASM can be a huge win.
In cases where the performance is fine either way, being able to use one language server and client is a huge win. I am already doing useful things with WASM and Rust. It is a very very nice workflow.
Of course I was making sure to do as minimal memory transfer as possible, and I already use a lot of weird patterns to try to minimize GC in JS.
https://github.com/magcius/noclip.website/blob/master/src/gx...
https://github.com/magcius/noclip.website/blob/master/src/as...
If you're doing a lot of cheap calls, it's probably not the optimal way to get a performance boost. I think Web Assembly shines at taking an expensive function, and doing it faster. For example, let's say I wanted to multiple a few large matricies of values. In Javascript this would be VERY slow. In Web Assembly it would be a bit faster, but then Web Assembly plus Web GPU allows me to do it REALLY fast. Yes, I'd then have to marshal the end result back to javascript but that's still cheaper then trying to do all that math natively in Javascript.