4 ms·
Can WebAssembly be used without any JavaScript? Or JavaScript is always required in some combination with it?
by shmerl 8y ago
Can WebAssembly be used without any JavaScript? Or JavaScript is always required in some combination with it?
- raboukhalil 8y agoFor now, JavaScript is required to initialize the WebAssembly module.
- shmerl 8y agoWhy was it not given same <script> level usage?
- steveklabnik 8y agoHow 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...)
- shmerl 8y agoYou mean for one module to import another? I guess you can use list them all first?
- deleted 8y ago[deleted]
- archgoon 8y agoIt 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.
- deleted 8y ago[deleted]
- shmerl 8y agoThanks for clarifying the reason behind it!
- hutzlibu 8y agoWouldn'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.
- soylentgraham 8y agoI 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/ 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)