Kotlin in WebAssembly

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

Kotlin Wasm

A few years ago, the Kotlin team introduced experimental WebAssembly support for the browser: A Kotlin Native wasm32 LLVM-based compiler target. 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 was released as experimental, and required the Wasm runtime to support the then-experimental Wasm-GC proposal. Kotlin Native wasm32 target was deprecated. In late 2023, Wasm-GC was enabled by default in Chrome and Firefox, and Kotlin/Wasm went Alpha.

Kotlin on JRE

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

Uses

Kotlin/Wasm can be used in browsers. At the time of this writing, KoWasm (see below) has WASI support. But because it requires the new 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/Wasm is in Alpha, but requires a version of the Wasm runtime that supports Wasm Garbage Collection (Wasm-GC).
  • Sebastian Deleuze is working on WASI Kotlin support as KoWasm.

Learn More

Here are some great resources: