News for hackers. Stuff that matters.
Re:Rust and WebAssembly in 2019 by shmerl on Saturday December 15, 2018 @09:42PM (#18691474)
Can WebAssembly be used without any JavaScript? Or JavaScript is always required in some combination with it?
Re:Rust and WebAssembly in 2019 by archgoon on Sunday December 16, 2018 @01:13AM (#18691986)
It cannot be used without javascript because it currently has no interface to the DOM.

Without DOM access, you're simply running a virtual machine isolated from everything else, and that would serve no purpose aside from burning clock cycles :).

It is currently felt that Webassembly shouldn't be given access to the DOM until after a garbage collection interface is created. Until that happens, any object given to the WASM runtime cannot be safely destroyed, as the browser doesn't know, and WASM has no way of indicating, that something, such as a reference to a div element, is still needed.

Currently, the simplest[1] and most secure way of working out how a given runtime should interface with the browser is to build that compatibility layer in javascript, and expose callbacks to the WASM runtime(which is defined). This lets developers write their own DOM-interface shim, allowing them to explore the possibility space, and not accidentally restrict which languages can be implemented in WASM.

[1] From the point of view of browser vendors and standards bodies.

Re:Rust and WebAssembly in 2019 by shmerl on Sunday December 16, 2018 @01:27AM (#18692016)
Thanks for clarifying the reason behind it!
Re:Rust and WebAssembly in 2019 by hutzlibu on Sunday December 16, 2018 @08:09AM (#18692911)
Wouldn't it be a good solution for certain use cases like games, if you introduce a special mode with just one canvas?

So you allways have one and only one canvas for the output in which you write directly, via webgl or without. No need for a gc here as that canvas inly gets removed qhen the site closes.

Re:Rust and WebAssembly in 2019 by soylentgraham on Sunday December 16, 2018 @05:52AM (#18692564)
I assume you're talking only in the context of web browsers... But if you're not, and for clarification, webassembly is not a web-browser-only thing. https://webassembly.org/docs/non-web/ I personally want to use webassembly in a few non-browser tools/apps, but currently it's doesn't seem well supported (I've not run anything outside v8 or javascriptcore yet)
Re:Rust and WebAssembly in 2019 by raboukhalil on Saturday December 15, 2018 @09:50PM (#18691495)
For now, JavaScript is required to initialize the WebAssembly module.
Re:Rust and WebAssembly in 2019 by shmerl on Saturday December 15, 2018 @09:57PM (#18691512)
Why was it not given same <script> level usage?
Re:Rust and WebAssembly in 2019 by steveklabnik on Sunday December 16, 2018 @01:47AM (#18692062)
How do you set up the imports with script?

(This would be one of the major design questions with such a thing. Not insurmountable! But given you’re already connecting it to JS functions...)

Re:Rust and WebAssembly in 2019 by shmerl on Sunday December 16, 2018 @01:54AM (#18692078)
You mean for one module to import another? I guess you can use list them all first?