Welcome to Kairo
Warning

The language reference describes Stage 1 Kairo. Not the Stage 0 compiler. Stage 1 is still under development and the syntax and standard library may change before 1.0. The Stage 0 compiler is stable and can be used to build Kairo programs, but it does not yet support all Stage 1 features.

Kairo

Kairo is a statically typed, compiled systems language with native bidirectional C++ interoperability. C++ projects can #include Kairo files directly. Kairo code calls C++ libraries without a binding layer. The compiler emits ABI-compatible object code that links with GCC, Clang, or MSVC output.

import std
 
ffi "c++" import "engine.hh" as engine
 
fn main() {
    var ctx = engine::create_context()
 
    try {
        engine::run(ctx)
    } catch e: std::Error::Runtime {
        std::println(f"engine failed: {e}")
    }
}

Why Kairo

Full control, less friction. Kairo gives you manual memory management, raw pointer access, struct layout control, and zero-cost abstractions with a compiler that tracks lifetimes, promotes smart pointers, and catches null dereferences at compile time. You opt into safety by default and opt out explicitly when you need to.

C++ interop that works both ways. ffi "c++" imports C++ headers and makes every declaration available as a native Kairo symbol. The kcc driver lets C++ code #include "file.k" with no code generation step. Templates, concepts, classes, and smart pointers cross the boundary cleanly.

Zero-cost abstractions. Interfaces are structural and carry no vtable. Generics are monomorphized. Panic handling compiles to tagged returns and branches no unwinding tables, no runtime. Virtual dispatch exists only when you write virtual.


At a Glance

import std

struct Point {
    var x: f64
    var y: f64
}

extend Point {
    fn length(self) const -> f64 {
        return std::sqrt(self.x * self.x + self.y * self.y)
    }

    fn op +(self, other: Point) -> Point {
        return Point { x: self.x + other.x, y: self.y + other.y }
    }
}

enum <T> ParseResult {
    Ok    { value: T },
    Error { message: string },
}

fn try_parse_point(input: string) -> ParseResult<Point> {
    var parts = input.split(",")

    if parts.len() != 2 {
        return ParseResult::Error { message: f"expected 'x,y', got '{input}'" }
    }

    var x = std::parse<f64>(parts[0].trim())
    var y = std::parse<f64>(parts[1].trim())

    return ParseResult::Ok { value: Point { x: x, y: y } }
}

fn load_config(path: string) panic -> Point {
    var content = std::read_file(path)

    if content.len() == 0 {
        panic std::Error::IO("config file is empty")
    }

    return try_parse_point(content).value
}

var a = Point { x: 3.0, y: 4.0 }
var b = Point { x: 1.0, y: 2.0 }

std::println(f"sum length: {(a + b).length()}")

match try_parse_point("1.5, 2.5") {
    case .Ok(var value) {
        std::println(f"parsed: ({value.x}, {value.y})")
    }
    case .Error(var message) {
        std::println(f"failed: {message}")
    }
}

var origin = try {
    load_config("origin.conf")
} catch {
    Point { x: 0.0, y: 0.0 }
}

std::println(f"origin: ({origin.x}, {origin.y})")

Status

Kairo is in active development. The compiler is currently in Stage 0 a C++ implementation that transpiles Kairo to C++. Stage 1 (self-hosted compiler written in Kairo) is underway.

Language syntax and standard library APIs may change before 1.0. The documentation on this site reflects the current language design.

Built by the Kairo Software Foundation.


Next Steps