3 ms·
Will there be a DOM api for wasm?
by humanwhosits 4y ago
Will there be a DOM api for wasm?
- cogman10 4y agoProbably never an official one. That'd sort of defeat some of the point of WASM. What already exists is multiple bridge libraries to make porting stuff from JS -> WASM and back again easier. For example: https://rustwasm.github.io/wasm-bindgen/examples/dom.html https://rustwasm.github.io/wasm-bindgen/examples/dom.html
- NohatCoder 4y agoNever say never, but the DOM and JavaScript environment relies pretty heavily on garbage collection. WASM is inherently not garbage collected, and that makes it really hard to share data between the environments, so I'd say that it is unlikely.
- wffurr 4y agoThere's nothing about WebAssembly that's "inherently" not garbage collected. There is a "Host GC" proposal [0] along with a "reference type" proposal that would allow holding handles to DOM or JS objects from WebAssembly and using the JS GC for WebAssembly objects. [0]: https://github.com/WebAssembly/gc/blob/main/proposals/gc/Overview.md https://github.com/WebAssembly/gc/blob/main/proposals/gc/Ove...
- astrange 4y agoThat's not an issue if you have a way to pin/unpin references as they move into the non-GCed world; a lot of GCed languages like Java/Python have native bridging. It is a good way to get memory leaks, but a lot of websites already have those.
- Sankozi 4y ago