Re:Learn WebAssembly by writing small programs
by plopz on Tuesday September 05, 2023 @04:13PM
(#37397103)
In the browser, can it integrate with SharedArrayBuffer, worker's postMessage or transferrable offscreen canvas?
[ Parent
| on HN ]
Re:Learn WebAssembly by writing small programs
by ReleaseCandidat on Tuesday September 05, 2023 @04:32PM
(#37397306)
Depends what you mean by "integrate". It always has to import or export JS functions or memory. WASM (without WASI) has no direct connection to "the outside World", everything has to be routed via JS FFI. So you can import or export a SharedArrayBuffer to communicate with JS.
https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScr...
But you need the WASM thread extension (for atomic access to the shared memory) to be able to use shared memory.
Re:Learn WebAssembly by writing small programs
by connicpu on Tuesday September 05, 2023 @04:30PM
(#37397276)
WASM essentially can call javascript functions that were imported, and I believe javascript is able to read WASM's memory (a big help for transferring strings). If you're using something like Rust, all the glue code to call any JS APIs can be automatically generated for you with wasm-bindgen, so it really isn't a huge problem usability wise. It's just not great for performance.