Tech

Minikotlin introduces browser-based Kotlin compiler that runs entirely client-side

The new open-source project allows developers to compile and execute multi-file Kotlin code directly in a web browser, leveraging WebAssembly Garbage Collection for native object-oriented support.

Author
Owen Mercer
Markets and Finance Editor
Published
Draft
Source: Hacker News · original
Tech
No image available
From-scratch C toolchain emits WebAssembly GC bytecode without JVM or LLVM dependency

Minikotlin, a newly introduced compiler written from scratch in C, enables the execution of Kotlin source code entirely within a web browser tab. The toolchain is compiled to WebAssembly (WASM) itself, allowing developers to input .kt files and receive running .wasm modules without requiring external infrastructure such as the Java Virtual Machine (JVM), LLVM, Binaryen, or Gradle.

The project utilises the WebAssembly Garbage Collection (GC) extension to support complex language features, including multi-file projects, classes, virtual dispatch, and coroutines. By emitting WASM-GC bytecode by hand, Minikotlin avoids the performance and complexity constraints often associated with running full-featured compilers in a browser environment.

Internally, the compiler’s frontend, referred to as 'mkf', handles the lexer, parser, and semantic analysis before handing off to two internal intermediate representations. These representations then write the final WASM-GC bytecode, ensuring that language constructs are properly lowered onto concrete WASM-GC mechanisms rather than relying on interpreted or token-subset approaches.

Specific mappings include treating every class as a GC struct type with properties as real struct fields, using struct.new for allocation, and implementing virtual calls via function-reference loads and call_ref. Type checks and smart-casting compile to ref.test and ref.cast, while coroutines are handled by splitting functions at suspension points and capturing continuations as closures, avoiding blocking or Asyncify.

To support development, the project includes a browser-based Studio that highlights multi-file Kotlin code using the compiler’s own lexer and runs the resulting WASM modules in place. The toolship includes end-to-end tests for its lowering processes, validating that features such as sealed interfaces and coroutine scopes function as intended within the client-side environment.

As a niche implementation, Minikotlin offers a lightweight development environment for browser-based compilation. However, it may lack the extensive ecosystem support and mature debugging tools associated with established Kotlin toolchains, and performance constraints may limit its suitability for large-scale production builds compared to traditional JVM or native options.

Continue reading

More from Tech

Read next: Open-source tool claims 97 per cent token savings for AI agents
Read next: Valvoline Unveils August 2026 Promotional Offers for Service and Retail Buyers
Read next: Developer Antirez releases native MiniMax H3 inference engine for Apple Silicon