I’m trying to wrap my head around everything Kotli...
# webassembly
a
I’m trying to wrap my head around everything Kotlin and had quick question (hopefully). What is the difference between Kotlin/Wasm and Kotlin/JS other than the delivery mechanisms? (IIUC, kotlin/wasm -> wasm, kotlin/js -> js files). Is kotlin/wasm meant to enable the same thing as kotlin/js and eventually replace it?
r
In general yes. Kotlin/WasmJs can do the same things as Kotln/JS. The API is a bit different when it comes to JS interop, so you can't just take any K/JS code and compile it to K/WasmJs without any changes. As for replacing K/JS I hope JB will continue to support both targets.
e
the HTML DOM and JS evolved together, so they are very tightly integrated. but it is a challenge to make JS perform predictably well
WASM was designed from the start to be a simple virtual machine, easy to make secure and fast. but it lacks direct access to the DOM in browsers, requiring messaging to JS code to perform DOM actions on its behalf
a
Ahh interesting, thanks both! So would there be a reason to use one over the other (k/js vs k/wasm)? I do see that k/wasm is still alpha, but if that wasn’t the case, what requirements would make someone choose a particular one?
e
Kotlin/WASM depends on GC, and you can see that there are still some browsers that don't have releases supporting it: https://webassembly.org/features/ (most notably Safari). plus other people in here have noted that if you're targeting other embedded users like smart TVs, many of those also haven't been updated
🙌 1
if you do have the option of WASM for your target audience, it may still depend on whether you need performance or integration with Javascript APIs more
gratitude thank you 1
r
My framework runs almost twice as fast with the Wasm target (compared to JS), although its main purpose is DOM manipulation and JS integration. So it's not an obvious choice.
a
integration with Javascript APIs more
What do you mean by this? Is this the “messaging” requirement you were talking about above?