Capability
Concepts describe the operations code requires. Concrete types are checked at compile time and specialized through monomorphization.
The Kinglet programming language
using io;
enum Shape {
Circle(float),
Rect(float, float),
}
float area(Shape s) {
return s match {
Shape::Circle(let r) => 3.14 * r * r,
Shape::Rect(let w, let h) => w * h,
};
}
int main() {
Shape c = Shape::Circle(1.0);
io::out.line(area(c));
return 0;
} Language
Kinglet makes four questions visible in the program: what the code can do, who owns a resource, how an operation can fail, and whether every state has been handled.
Concepts describe the operations code requires. Concrete types are checked at compile time and specialized through monomorphization.
Scalars, shared values, and resources follow distinct transfer rules. Resources use moves and explicit borrows to express lifetime responsibility.
Fallible conversions produce T?; ?: supplies a fallback, postfix ? propagates failure, and try / catch defines recovery.
Postfix match destructures enums, structs, and arrays. The compiler checks state coverage for enums, booleans, and optionals.
In code
Nullable types, propagation with ?, and try / catch make error paths visible instead of implicit.
Explore the syntax →using io;
int? parse(string s) {
return int(s)? * 10;
}
int main() {
int? a = parse("42") ?: -1;
io::out.line("a = {}", a);
int n;
try {
n = int("bad")?;
} catch (let ex: CastError) {
n = -99;
}
io::out.line("n = {}", n);
return 0;
} Toolchain
The bootstrap compiler covers parsing, semantic checking, Kinglet IR, LLVM lowering, a small runtime, and the command-line driver — all in one binary.
Get started
curl -fsSL https://kinglet-lang.org/install.sh | shcurl -fsSL https://kinglet-lang.org/install.sh | shirm https://kinglet-lang.org/install.ps1 | iex