Skip to content

Getting started ​

Mini is a Kotlin compiler. You write .kt files, minic turns them into C17 and clang links the result with a small C runtime into a native executable.

Just want to use Mini?

Install a prebuilt release with one command (no JDK needed), or try the compiler in your browser in the tutorial. Start with the installation guide if you want to choose between a project and a standalone file. The checkout instructions below are for working on Mini itself.

Requirements ​

NeededWhy
clang (or gcc)compiles the generated C
A release (install.sh) or a checkout of the repositorythe tools locate their bundled runtime and standard library from the toolchain installation
libuv (optional)only needed to run the runtime test suite, not to compile programs

Supported platforms are Linux (x64, arm64) and macOS (Apple silicon). Windows is planned.

Install the project tool and compiler ​

sh
curl -fsSL https://raw.githubusercontent.com/HenrySchwerdt/mini/main/install.sh | sh
export PATH="$HOME/.mini/bin:$PATH"
mini new hello && cd hello && mini run

mini is the native project tool (no JVM, no Gradle), minic the driver for explicit source files; the command line reference lists its commands. In a checkout, ./mini new hello builds the tool and the native compiler on first use without Gradle.

Build the native toolchain from a checkout ​

sh
git clone https://github.com/HenrySchwerdt/mini
cd mini
./minic build examples/hello.kt -o build/hello

The ./minic and ./mini scripts build the native toolchain (build/native) on first use, and again whenever its sources are newer than the installed binaries, then run it. You can also build it explicitly:

sh
./mini --version

Hello, world ​

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

Output, produced by building and running exactly this file in CI:

text
Hello, Mini!
1 * 1 = 1
2 * 2 = 4
3 * 3 = 9

minic build takes one or more .kt files (exactly one has fun main()), the output path with -o, and a few options. See the command line reference.

./minic check: only the memory checker ​

sh
./minic check examples/memory_leak.kt

check runs the front end and the Strict-mode ownership checker and stops there: no C is generated and nothing is linked. It prints diagnostics on stderr and exits with status 1 if there is an error. --brief prints only line:col: CODE lines on stdout. minic build runs the same checker before code generation, so an error stops the build too.

Every file is parsed and type-checked. A file opting in with @file:MemoryMode(Mode.Strict) also has tracked ownership obligations checked; Managed code can still report ordinary syntax and type errors. The memory guide explains what is checked.

Where to go next ​

Released under the Apache License 2.0.