Hacker News new | ask | show | jobs
by mlevental 2999 days ago
rust compiles to web assembly
1 comments

What kinds of things could you do with web assembly that you can’t do in native JavaScript? I know very little about web development.
It gets you very close to native performance while running in your browser and browser sandbox. That's mind-blowing.

You'd still use JS for UI stuff, but WASM lets you run algorithmic or CPU intensive tasks like e.g. games, video decoding, image resizing, AI, or anything else you need fast performance for client-side.

There was a demo the other day of Rust outperforming JS for stuff JS usually does. Presumably this will continue to improve, so it won't even be a case of equivalent, it'll be a case of "thoroughly beats the pants off".
"Very close to native" means "much more efficient than JS", because JS is nowhere near native.

(Have we really gone so far that people hear "native" and think of the browser? Like the web browser is the machine we target, and not the metal box the end user purchased?)

Is it pretty easy to write C++ extensions to V8? I've seen a couple of projects of that sort. I wonder if they're relatively difficult, and if that's perhaps why the push for WebAssembly has been so strong.
Mostly it lets you not use JavaScript, which you may or may not be excited about, depending on how much you think the problem with web development is JS.
There are plenty of languages that compile to JavaScript. They don't save you from having to interface with the DOM and other JavaScript APIs, but neither does WebAssembly (which currently has no such capabilities at all, save through JavaScript FFI).
You can run code written in a language you are comfortable with and run web code really, really fast. It's not an "either JS or WebAssembly", they can work together. Worth reading up on if you are interested - https://developer.mozilla.org/en-US/docs/WebAssembly
I know that the web wallet for NANO uses wasm to generate hashes, and is _much_ more performant than the JS equivalent.