Live data from Hacker News

WebAssembly support now shipping in all major browsers

blog.mozilla.org

71–80 of 346 posts

Re: WebAssembly support now shipping in all major browsers

#72
post #68

Can anybody ELI5? The documentation is pretty fluffy. Does WebAssembly actually open up any new API hooks? I get that its a clever way of transpiling existing programs to JavasScript, but surely we could do that already? Whats new avenues of development is WebAssembly expected to open up? Is the whole point just to enable an easy way to compile games made on other platforms (Unity) to the web?

I can address at least the first misconception here - this isn’t transpilation to JS. This is native code that has browser APIs exposed to it, so in theory there should be massive performance wins.

Re: WebAssembly support now shipping in all major browsers

#73
post #27
post #21

Earlier quoted context omitted.

I think it's darkly humorous that I have to install browser plugins to stop sites from mining monero in my browser. It's like websites are those creepy spider things in the Matrix, except instead of sticking humans in pods to harvest their biochemical energy, they're just running up our home electricity bills by maxing our CPUs.

What plugins do you recommend for this?

uBlock Origin with the default choice of lists plus "Fanboy's Annoyance" makes the web 100s of times faster.

It's now a default install on every browser of every computer I touch. Even on Firefox on Android, which works really well btw.

Re: WebAssembly support now shipping in all major browsers

#74

For those in the know, what doors is web assembly expected to open? Better cross platform platforms via a browser wrap? Will new types of browser applications be possible that aren't now in JS only world? What are they?

give me qt over js+css any time.

Re: WebAssembly support now shipping in all major browsers

#75
post #68

Can anybody ELI5? The documentation is pretty fluffy. Does WebAssembly actually open up any new API hooks? I get that its a clever way of transpiling existing programs to JavasScript, but surely we could do that already? Whats new avenues of development is WebAssembly expected to open up? Is the whole point just to enable an easy way to compile games made on other platforms (Unity) to the web?

WASM is used to run native code in the Web browser without going through JavaScript. With it, it should be possible to run code at near-native performance in the browser.

WASM is an intermediate representation which is output by your compiler (of your favorite language) and consumed by the browser's compiler to emit native code.

WASM is a bit similar to LLVM IR, but it's architecture independent.

Compare this to, say, LLVM and Clang. Clang (the C compiler front end) will read C code and emit LLVM IR. LLVM (the compiler backend) will read LLVM IR and emit assembly code for your CPU. With WASM, the developer will run the "front end" and distribute the WASM code over HTTP and the web browser will run the backend and turn WASM into native assembly code.

> I get that its a clever way of transpiling existing programs to JavasScript, but surely we could do that already?

No, WASM code is not JavaScript at any point. ASM.js is a predecessor to WASM that was a compiler-friendly variant of JavaScript that can be compiled to native code.

Re: WebAssembly support now shipping in all major browsers

#76
post #34

A good occasion to watch Gary Bernhardt's talk "The Birth & Death of JavaScript" [0] again, where he talks about the precursor of WebAssembly: asm.js and the future implication it "could" have in the future in a really humorous way. A few years old but still relevant. You want Gimp for Windows running in Firefox for Linux running in Chrome for Mac? Yeah sure. [0] https://www.destroyallsoftware.com/talks/the-birth-and…

Also relevant: callahad a few weeks ago: https://twitter.com/nybblr/status/923569208935493632

Netscape navigator on DOS in Firefox via WebAssembly.

Re: WebAssembly support now shipping in all major browsers

#77
post #68

Can anybody ELI5? The documentation is pretty fluffy. Does WebAssembly actually open up any new API hooks? I get that its a clever way of transpiling existing programs to JavasScript, but surely we could do that already? Whats new avenues of development is WebAssembly expected to open up? Is the whole point just to enable an easy way to compile games made on other platforms (Unity) to the web?

WebAssembly is a specification of a small assembly language. This language can call into functions in its host environment. The "web" part is that all evergreen web browsers have implemented this language, and you can use it from inside your browser, and call JavaScript functions into it.

This means that WebAssembly is actually broader than just the web; for example the Etherium folks have been discussing using wasm as their language to script their blockchain.

It doesn't currently open up any real new API hooks; it's mostly about being an efficient language for computation. You get near-native performance in the browser. In the future, it may or may not grow more hooks directly into the web platform, rather than needing to call into JS to do so.

Re: WebAssembly support now shipping in all major browsers

#78
post #56
post #53

Earlier quoted context omitted.

That's true as far as it goes - but wasm lacks general "goto" instructions (across procedures), and loops only work for self-tail-calls. There's an expressiveness gap between languages with and without proper tail calls. (Unless you're willing to accept the unsafe-for-space solution.)

I think it would still be possible to implement Scheme with the current specification, which is on my snowy weekends to do list for the upcoming Winter. How far I would get before losing interest or facing those issues, I don't know.

It's possible, yes, but it isn't possible to do particularly efficiently. If you want separate compilation, it gets even worse. (Separate compilation is where proper tail calls come in very handy.)

Re: WebAssembly support now shipping in all major browsers

#79
post #68

Can anybody ELI5? The documentation is pretty fluffy. Does WebAssembly actually open up any new API hooks? I get that its a clever way of transpiling existing programs to JavasScript, but surely we could do that already? Whats new avenues of development is WebAssembly expected to open up? Is the whole point just to enable an easy way to compile games made on other platforms (Unity) to the web?

I can address at least the first misconception here - this isn’t transpilation to JS. This is native code that has browser APIs exposed to it, so in theory there should be massive performance wins.

This is also a misconception, it is just a bytecode. asm.js is already running at around 50% native speed so there is no massive performance wins to find. What you get with WebAssembly is reduced startup time because it doesn't have to be parsed first.

The really exciting thing people should be talking about is not WebAssembly but the general availability of SharedArrayBuffer[0] which finally makes it possible to run "foreign" multi-threaded code efficiently.

[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: WebAssembly support now shipping in all major browsers

#80
post #58

How do I compile/target stuff for WebAssembly and integrate it with "usual web" (I need to use some advanced math & WebGL real-time that is too slow in JS)? Is there any good tutorial? Thanks!

Currently, the best supported languages are C, C++, and Rust. Languages that have runtimes require their runtimes to also be compiled in, and so are much heavier weight.

For C and C++, you have emscripten. For Rust, we have an emscripten-based toolchain that works today, but have a PR open for using LLVM's built-in wasm backend.

For emscripten: https://kripken.github.io/emscripten-site/docs/#

For Rust: https://hackernoon.com/compiling-rust-to-webassembly-guide-4... (slightly older but still should work afaik) And the new backend https://github.com/rust-lang/rust/pull/45905

Post reply on HN