Kotlin in WebAssembly

Kotlin, like .NET, has an interesting history with WebAssembly.

Kotlin Native (or Kotlin/Wasm)

A few years ago, the Kotlin Native team introduced WebAssembly support for the browser. However, in 2019 they began a rewrite of the feature. In late 2020, they demoed the upcoming version, called “Kotlin/Wasm”. In early 2023, the new version reached Beta, but requires the Wasm runtime support the experimental Wasm-GC proposal.

Kotlin on JRE

Kotlin compiled to Java bytecode can be executed by the Java-to-Webassembly tools.

Uses

In-browser support for Kotlin has been available for a few years. The new rewrite, though, is set to replace the older implementation. At the time of this writing, KoWasm (see below) has WASI support. But because it still requires the Wasm-GC extension, Spin will not support it until Wasmtime supports Wasm-GC. Therefore, we do not know whether Kotlin can be used to create Fermyon Cloud applications.

Available Implementations

  • Kotlin-Native can be compiled to WebAssembly, but this method is going away.
  • The new compiler is in beta, but requires a version of the Wasm runtime that supports (experimental) Wasm Garbage Collection (Wasm-GC).
  • Sebastian Deleuze is working on WASI Kotlin support as KoWasm.

Learn More

Here are some great resources:

Interested in learning more?

Talk to us