https://kotlinlang.org logo
#compose-web
Title
# compose-web
m

Michael Paus

11/12/2023, 10:08 AM
Kotlin and Java interoperability on WebAssembly platform. One of the strong points of Kotlin has always been its seamless interoperability with Java. Now, with Kotlin multiplatform, we completely loose that benefit as soon as we leave the JVM and Android realm. I am wondering whether this strong point could be brought back via WebAssembly. Both, Kotlin and Java can be compiled to WA and even the native parts of libraries, written in C/C++, can be compiled to WA (see for example what can be done with https://cheerpj.com/). So, I am wondering whether there are any plans to unite Kotlin and Java again in such a way that I can write Compose applications for the WA platform with the same ease as I can write pure desktop applications today where I can seamlessly mix Java and Kotlin code.
e

ephemient

11/12/2023, 10:14 AM
CheerpJ and other Java to WASM compilers work on the bytecode level, which means Java knows nothing of WASM, but you could compile your Kotlin code together with Java as you do on the JVM
m

Michael Paus

11/12/2023, 10:17 AM
Yes, of course, but this would probably not work easily for a full Compose desktop application.
e

ephemient

11/12/2023, 10:21 AM
there is no standard for interoperability now
I expect https://github.com/WebAssembly/component-model or something like it will come along in the future
at that point, as long as both Kotlin/WASM and the other libraries you want to interact with adopt it, the goal is that they would be able to
m

Michael Paus

11/12/2023, 11:28 AM
Yes, the still missing standard for interoperability is the central problem here. Waiting for such a standard to appear is one way of dealing with this. Another option would be to create a Java classfile to WASM transpiler which is compatible with the way the Kotlin compiler compiles to WASM in the same way as it is done on the JVM. This could probably only be done by JetBrains and the question is whether JB has any interest in that.
n

Nikita Lipsky

11/13/2023, 12:18 PM
Bringing Java to WASM or to native actually means supporting the whole JVM semantic for that targets to say it works. JetBrains does not plan to do that
11 Views