HeadlinesBriefing favicon HeadlinesBriefing.com

minikotlin: Kotlin compiler runs in browser tab

Hacker News •
×

minikotlin is a Kotlin compiler written in C that emits Web Assembly GC bytecode by hand—no JVM, no LLVM, no Binaryen, no Gradle. The compiler itself is compiled to WASM‑GC, so .kt source goes in and a running .wasm module comes out entirely in the tab, backed by backend structs, call_ref and EH server for client‑side end‑to‑end tests.

The pipeline is a single pass from source to bytecode. The frontend lexer, parser and semantic analysis (mkf) hand off to two IRs before emitting WASM‑GC by hand. Multiple .kt files are compiled as one unit, passing 657 frontend tests.

minikotlin supports full Kotlin: classes, inheritance, interfaces, data classes, sealed types, smart‑casts, null safety, generics, operators, coroutines, and a hand‑written standard library. Lowering maps language constructs to WASM‑GC: class → struct.new, virtual call → call_ref, type check → ref.test, coroutine → CPS closure.

A sample program shows a sealed class Lane with Fast and Slow, a pace function, and a coroutineScope that launches two delayed coroutines. The suspension is compiled to continuation closures, demonstrating real coroutine support without Asyncify or threads.