Mk language
A small systems language compiled through LLVM: ownership, borrowing and linear values checked from signatures, arenas as the default allocator, and structured tasks.
Overview
Mk is a small, statically typed systems language for software that has to be fast and correct: tools, servers, runtimes and kernels. Its compiler checks ownership, borrowing and linear values from signatures alone and reaches native code through LLVM, with no garbage collector and no C runtime.
Code
export Main(sys: &System): WriteError!void {
n := 41 // `int`: the type comes from the value
try sys.Print("{m}\n", (m: n *% 2)) // `*%` wraps where `*` would panic
}
enum Shape {
Circle(r: f64)
Rect(w: f64, h: f64)
}
Half(): f64 {
s := Shape.Rect(w: 2.0, h: 3.0) // every field is named
area := match s { // every variant, no `_` needed
.Circle(r) { 3.14159 * r * r }
.Rect(w, h) { w * h }
}
return area / 2.0
}
Max[T: Ord + Plain](xs: []T): ?T { // the bound says what the body may do
if xs.Len() == 0 {
return none
}
var best := xs[0]
for x in xs {
if best.Less(&x) { best = x }
}
return some(best)
}
Top(): int {
return Max([3, 1, 4][..]).Must() // `Must` panics on `none`
}
Bump(n: mut int) {
*n += 1
}
export Main(sys: &System): OutOfMemory|WriteError!void {
var n := 0
scope s := sys.io.Scope() { // the block joins its tasks
s.go Bump(mut n) // a task may borrow a local
}
var arena := try Arena.New(sys.heap)
defer arena.Free() // what was made in it goes too
upper := try "mk".ToUpper(&arena)
try sys.Print("{upper} {n}\n", (upper, n))
}
A literal, its wrapping operator and
try; a value taken apart by match; a generic under a bound. A task joined by scope; an arena freed whole.Distinctive traits
- Borrowing without lifetimes: values hold the loans they depend on, and
from/intoclauses replace lifetime parameters. - Arenas are the default:
List,MapandTextare freed with their region, so most functions never release memory. - Linear values replace destructors: a file or arena must be consumed exactly once on every path, so a forgotten close is a compile error.
- Every fallible signature names its error set;
tryis a prefix and integer overflow traps in release builds too. - Structured concurrency: a
scopeblock joins its tasks, so a task may borrow a parent's local and conflicting loans do not compile. - Small by design: no macros, no inheritance, no implicit conversions; generics, contracts, compile-time evaluation,
unsafeblocks and C interop stay.
Status
Mk 0.2.1 shipped in November 2026 under MIT, with release bundles for Windows,
Linux on x86-64 and ARM, and Apple silicon. A module is a directory; a package
is a pkg.mk manifest. Pre-1.0, a minor release may change stable items.
Sources & references
- Official sitegithub.com
- A tour of Mk - the language one feature at a timegithub.com
- The Mk memory model - ownership, loans and rules R1 to R21github.com
- The Mk language reference - the language, rule by rulegithub.com
- Why Mk looks like this - design rationale and lineagegithub.com
- Mk changelog - releases 0.1.0 to 0.2.1github.com