https://kotlinlang.org logo
#webassembly
Title
# webassembly
b

Big Chungus

10/21/2021, 2:54 PM
I was hoping to see some kjs kwasm interop
s

Svyatoslav Kuzmich [JB]

10/21/2021, 4:22 PM
I can see how such interop might look like an intuitive thing to support. But seamless interop between different Kotlin platforms is a very very big and complex feature, both in terms of design and implementation. For instance, many values, like arrays and lists would become incompatible between different platforms. We would have to either copy them or make wrappers. Both Kotlin/JS and Kotlin/Wasm are interoperable with JS. I think it would be possible to define common
external interface
and pass these values around via JavaScript if you would want to have K/JS and K/Wasm in the same project. Better yet would be to make your code multiplatform, so K/JS users would compile it to JS and K/Wasm to Wasm.
b

Big Chungus

10/21/2021, 4:24 PM
Oh no I get that it'd be hella complex. It's just me daydreaming for now 😀
Although if you can interop kjs and kwasm already through js and kjs compiles directly to js, I think it's reasonable to hope for some no-nonsense official interop between kjs and kwasm.
👍 4
Basically compiler could make some assumptions about what compiled js looks like and generate wasm bindings without us having to know about that
As for making project mpp instead, that'd only work for libraries in limited cases. However even for libraries, there's significant value in kwasm and kjs interop (e.g. game of life engine from the demo as a react component)
s

Svyatoslav Kuzmich [JB]

10/21/2021, 4:30 PM
It is sort of possible to do via feeding dukat d.ts files generated by Kotlin compiler. But this would be limited to JsExport-ed API surface.
b

Big Chungus

10/21/2021, 4:32 PM
Of course. I'm not expecting anything big, really. Just some way of making kjs and kwasm sourcesets aware of each other and passing data accross (can be limited to external interfaces only)
Basically making sure I don't have to touch js directly 😀 I feel dirty after each time i have to touch js...
5
r

rnett

10/21/2021, 4:34 PM
I'll second the general thought here, and Seb even mentioned it in the video ("use React or Compose for UI in JS, and hand off computationally expensive tasks to Kotlin/WASM"). Might have to wait for interface types, but it would be nice to have something here eventually.
2 Views