Skip to content

MiniKotlin, compiled to native code

Write ordinary Kotlin and get a small, fast native binary. When you need control, opt into manual memory management that the compiler checks for you.

hello.kt
data class Point(val x: Int, val y: Int)

fun main() {
    val pts = listOf(Point(1, 2), Point(3, 4), Point(5, 6))
    val total = pts.sumOf { it.x * it.y }
    println("Hello from native code: $total")
}
Install mini + minicLinux x64 and arm64, macOS on Apple silicon. Needs a C compiler, no JDK.
curl -fsSL https://raw.githubusercontent.com/HenrySchwerdt/mini/main/install.sh | sh
All install options

Install Mini ​

sh
curl -fsSL https://raw.githubusercontent.com/HenrySchwerdt/mini/main/install.sh | sh
powershell
curl.exe -fsSL https://raw.githubusercontent.com/HenrySchwerdt/mini/main/install.ps1 -o install-mini.ps1 && pwsh -File .\install-mini.ps1

The installers verify the release download and print the command to add Mini to your PATH. Windows x64 support is experimental. See installation and requirements.

Train it. Draw it. Try it. ​

Teach a model to recognize handwritten digits, then test it with your own mouse or touch input. The digit lab downloads real data over HTTPS, compares raw matrix multiplication with Linear, and shows three mini.plot APIs — all in an editable Mini notebook in your browser.

Open the digit lab → · Explore the libraries

Leaks are compile errors ​

Switch a file to Strict mode and the compiler tracks every allocation. This program forgets to release buf on the early-return path. Press Check: the checker runs in your browser.

kotlin
@file:MemoryMode(Mode.Strict)

import mini.memory.*

class Buffer(val size: Int) : AutoCloseable {
    override fun close() = println("close $size")
}

fun fill(b: Buffer): Boolean = b.size > 100

context(h: Heap)
fun load(n: Int): @Owned Buffer? {
    val buf = Buffer(n)
    if (!fill(buf)) return null    // leaks `buf`
    return buf
}

fun main() {
    context(Heap()) { load(8).free() }
}

The fix is to release on that path too (the fixed program is checked in CI like every example on this site). The same analysis finds double frees, use after free, use after move and arena escapes.

Plain Kotlin, native binary ​

kotlin
fun main() {
    val name = "Mini"
    println("Hello, $name!")
    for (i in 1..3) println("$i * $i = ${i * i}")
}
sh
minic build hello.kt -o hello && ./hello

Mini translates Kotlin through C17 (or LLVM IR) and links a small C runtime. There is no JVM at run time and no garbage collector. See how it works.

Where next ​

Status

Mini is a working research compiler. Linux and macOS are supported, and native Windows x64 support is experimental. The native mini project tool is available; coroutines and Windows threads remain planned. Strict mode is checked today, but native code generation for programs that use allocator types is still in progress. See Roadmap and status for the honest list.

Released under the Apache License 2.0.