Hi, can I compile my business logic into Kotlin/Wa...
# javascript
u
Hi, can I compile my business logic into Kotlin/Wasm and export it via
@JsExport
to use with my JS frontend?
e
Sure, with limitations at the moment. See kotlinlang.org/docs/wasm-js-interop.html#…
🙏 1
a
But for this use-case we (the Kotlin team) recommend to use JS: kotlinlang.org/docs/web-overview.html#…
u
Yeah, I already know how to do that 🙂 but I wanted to check if using Kotlin Wasm offers better performance than transpiling to JS.
I was thinking that once Kotlin/Wasm is stable, there wouldn't really be any point in transpiling to JS anymore, right?
a
Not really. Making the same level of interop with JS on Wasm at this point not so real. (making it perform better than transpiling to JS, double unreal) Even Wasm is stable, we still will recommend to use it for CMP only (talking about wasmJs target, and not wasmWasi;)
u
I understand, but for my use case, it's just a business logic component that I need to expose to JS; I don't need to call JS APIs. I think it would be better to use Kotlin Wasm, wouldn't it?
e
Start with JS, see what you end up with, then try to transition to Wasm and you'll see which blockers you hit.
And btw if you're "worried" about perf, you shouldn't. As an example, I have ANTLR parsers running through K/JS using github.com/Strumenta/antlr-kotlin, and never noticed any bottleneck. On the contrary, performance of the outputted code has increased almost with every major release.
b
Making the same level of interop with JS on Wasm at this point not so real.
I wouldn't say it's that unreal, but there will be trade-offs. And JS export improvements are out of scope of Stable.