Klar
No ambiguity. No surprises.
Klar is an applications programming language with explicit types, ownership, traits, and compile-time programming — designed for clarity, safety, and AI code generation.
Clear by design
Every line is self-describing. No context needed.
struct Point {
x: f64
y: f64
}
fn distance(a: ref Point, b: ref Point) -> f64 {
let dx: f64 = b.x - a.x
let dy: f64 = b.y - a.y
return (dx * dx + dy * dy).sqrt()
}
fn main() {
let origin: Point = Point { x: 0.0, y: 0.0 }
let target: Point = Point { x: 3.0, y: 4.0 }
let d: f64 = distance(ref origin, ref target)
println("Distance: {d}") // 5.0
}Everything you need
A modern applications language built from first principles.
Explicit Types
Every variable declares its type. No inference ambiguity — you never need to trace through code to know what something is.
Ownership & Safety
Memory safety without a garbage collector. Ownership model with ref/inout borrows — simpler than Rust, safer than C.
Traits & Generics
Trait-based polymorphism with monomorphized generics. Eq, Ordered, Clone, Drop, Hash, and more built in.
Comptime
Compile-time evaluation and reflection. Replace preprocessor macros with real code that runs at compile time.
FFI
Call C functions directly. Use C types, link C libraries — interop without wrappers or ceremony.
WebAssembly
Compile to WASM for browser and edge deployment. Same language, same safety, new platform.
Interactive REPL
Experiment and prototype interactively. Test ideas without a compile cycle.
AI-Native
Designed for AI code generation. Context-free grammar, keyword-driven syntax, and consistent patterns.
LLVM Backend
Native compilation via LLVM with -O0 to -O3 optimization, debug info, and cross-compilation support.
Three principles
Every design decision follows from these.
No ambiguity. No surprises.
Syntax is self-describing. Every construct is parseable at a glance without surrounding context. One way to do things, no implicit behavior, no undefined semantics.
and, or, not // keywords over symbols
let x: i32 = 5 // explicit types always
return a + b // explicit returns
x.as#[i64] // explicit conversions
a +% b // explicit overflowThe code explains itself.
Code carries its own intent, architecture, and decisions. The meta layer embeds “why” alongside “what” — no external documentation needed.
meta module {
purpose: "Token stream → AST",
role: "frontend"
}
meta decision("i32 not usize")
fn len(self) -> i32 { ... }Explicitness earns its characters.
Every annotation must justify its verbosity by preventing the reader from needing to look elsewhere. Simple code needs no annotations — complexity earns more.
// Earns its place — saves reading 3 files
meta decision("i32 not usize")
fn len(self) -> i32 { ... }
// Noise — the signature already says this
// meta intent("Takes string, returns int")
fn parse_int(s: string) -> ?i32Up and running in minutes
Three steps from zero to your first Klar program.
Install
git clone https://github.com/PhilipLudington/Klar
cd Klar && ./run-build.shWrite
fn main() {
println("Hello, Klar!")
}Run
klar run hello.kl
# Hello, Klar!