Philosophy

Philosophy

Kairo is a systems programming language built on one idea: you should have full control over your program without having to fight the language to get it.

The problem

Systems languages tend to fail in one of two ways.

Some give you unlimited freedom and no guardrails. You manage memory, track lifetimes, and audit every pointer yourself, and you hope that discipline holds across a million-line codebase that a rotating team maintains for a decade. When it doesn't hold, you get CVEs.

Others fix this by limiting what you can express. The compiler keeps rejecting your program until you restructure it to fit its model. That does produce safe code, but you pay in cognitive overhead. Simple patterns turn into puzzles, and prototyping starts to feel like negotiating with a bureaucracy.

Kairo tries to avoid both. The language should help you write correct code and leave the structure of that code up to you.

Design principles

There are four principles below, and they share one trade-off. Kairo moves accidental complexity out of your head and into the compiler, while keeping enough explicit information in the source that a person can still understand the code by reading it locally.

Lifetimes, ownership, null states, and panic paths are bookkeeping. They have nothing to do with the problem you're solving, so the compiler should carry them. It shouldn't carry the meaning of the code, though. If you have to ask the compiler, or read five other files, to know what a line does, the complexity has only been hidden. Inference handles the tedious parts, and anything that changes how you reason about a piece of code stays written down where you're reading it.

Control should exist

Kairo is a systems language. You can manage memory directly, control struct layout and alignment, use raw pointers, work across ABI boundaries, call C and C++ at zero cost, and write allocators, runtimes, compilers, or kernels. None of that is hidden from you.

Traditional systems languages also assume you want to do all of this by hand. Kairo doesn't. The compiler provides:

  • Ownership tracking and automatic smart pointer promotion
  • Null safety with compile-time null checks on safe pointers
  • Panic propagation analysis with exhaustive catch verification
  • Structural interface validation without explicit registration
  • Full-program lifetime analysis with no annotations required

You can override or opt out of any of these when you need to.

Safety should assist, not dominate

Kairo's safety features mostly make problems visible. They don't stop you from writing the code in the first place.

The compiler explains mistakes clearly, keeps what you meant intact, and stays out of the way while you experiment. It's lenient during development so you can move fast, and stricter when you build for release. The intended workflow is to prototype loosely, refine on purpose, and harden the code before it ships.

Each escape hatch is spelled out in the source. unsafe blocks suspend Tether tracking. unsafe *T pointers skip null checks and bounds analysis. unsafe function overloads relax semantic invariants. Because every dangerous operation is marked, a reviewer can find all of them with grep.

Code should explain itself

You shouldn't need an IDE, knowledge of hidden compiler behavior, or a tour through dense metaprogramming to understand what code does. This matters more the more work the compiler does for you, since a reader can only go by what's on the page.

  • self is always visible in method signatures
  • Inheritance uses the derives keyword, with no implicit resolution
  • Pointer types look different from each other (*T vs unsafe *T vs *const T)
  • All conversions use a single as keyword
  • Interfaces are structural: if a type has the methods, it satisfies the interface
  • Operator overloads are declared with fn op syntax that mirrors the operator
class Sensor {
    var reading: f64
    mutable var access_count: i32

    fn value(const self) -> f64 {
        self.access_count += 1
        return self.reading
    }

    fn calibrate(self, offset: f64) {
        self.reading += offset
    }
}

Open this in a plain text editor and you can still follow it. You can see which methods mutate, which fields stay mutable through const, and where the visibility boundaries are. Kairo treats readability as a requirement for systems code, including code written by experts.

Adoption should be incremental

Large codebases take decades to build, whole ecosystems are written in C and C++, and most teams can't afford to rewrite everything.

Kairo fits into an existing system one module at a time. You import C headers directly with ffi "c" and C++ headers with ffi "c++". Kairo emits ABI-compatible object code (Itanium on Unix and MinGW, MSVC on *-windows-msvc), so its .o files link against GCC, Clang, or MSVC output without shims. Object layout, vtable structure, name mangling, and calling conventions all follow the platform standards.

ffi "c++" import "engine.hh" as engine

fn main() {
    var ctx = engine::create_context()
    engine::run(ctx)
}

A team can move over one file at a time, check performance as it goes, and keep its existing build system the whole way through.

Zero-cost abstractions

High-level features compile to predictable low-level code:

  • Interfaces are structural and have no vtable or runtime dispatch cost. A type satisfies an interface by having the right methods, with no registration or indirection.
  • Generics are monomorphized at compile time, so there's no boxing, type erasure, or runtime cost.
  • Panic handling compiles to tagged return values and branches. There are no unwinding tables, no runtime exception handler, and no stack unwinding.
  • Tether runs at compile time. There's no garbage collector, and reference counting only appears where the analysis decides ownership is actually shared.
  • Virtual dispatch exists only when you write virtual. Non-polymorphic classes have no vtable pointer.

If you don't use a feature, it costs you nothing.

Familiar, but cleaner

Kairo should feel familiar if you've written systems code before. Most concepts carry over from C++, minus the complexity that doesn't earn its keep:

C++ complexityKairo simplification
static_cast / dynamic_cast / reinterpret_cast / const_castSingle as keyword
Implicit thisExplicit self parameter
public: / private: / protected: sectionsPer-declaration pub / priv / prot
const int* vs int* const ambiguityLeft-to-right const binding rule
Header/source splitSingle .k files
friend declarationsModule-level visibility (priv, prot)
#define preprocessorScoped token macros and AST attributes
Implicit special member generation/suppressionAlways generates unless explicitly deleted
Exception unwinding tablesZero-cost panic returns

Kairo isn't trying to be novel. It's trying to remove the friction C++ picked up over decades of evolution while keeping the power that makes C++ worth using.

Who Kairo is for

Kairo is meant for projects that keep growing, such as:

  • Compilers and language toolchains
  • Game engines and real-time systems
  • Distributed systems and infrastructure
  • Operating systems and embedded firmware
  • Long-lived enterprise codebases

It's for engineers who want the performance and control of systems programming without the maintenance burden that usually comes with it.