Designed for
machines to write.
Built for humans to trust.
Klar is the programming language where AI-generated code compiles correctly 95% of the time. No null. No exceptions. No ambiguity.
95%
First-pass correctness
−40%
Token usage
~3x
Faster than Node.js
$ curl -fsSL klar.run/install | sh
$ klar new my-app --template api
$ klar run
> Server running on :3000 ready in 0.8s
> AI compile check passed (0 warnings)
Side by side
Same feature. 71% fewer tokens.
User registration endpoint. Klar auto-generates validation, serialization, and error handling from the @schema annotation.
@schema
struct User {
name: String @min_len(1) @max_len(100)
email: String @format(email)
age: Int @range(0, 150)
role: Role = Role.Member
}
fn create_user(req: Request) -> Response ! AppError {
let input = req.json[User]()?
let user = db.insert(input)?
Response.json(user, status: 201)
}// Zod schema
const UserSchema = z.object({
name: z.string().min(1).max(100),
email: z.string().email(),
age: z.number().int().min(0).max(150),
role: z.enum(["admin", "member"]).default("member"),
});
// TypeScript type
type User = z.infer<typeof UserSchema>;
// Interface for response
interface UserResponse { ... }
export async function POST(req: Request) {
try {
const body = await req.json();
const input = UserSchema.parse(body);
const user = await db.insert(input);
return Response.json(user, { status: 201 });
} catch (err) {
if (err instanceof ZodError) {
return Response.json(
{ error: err.errors }, { status: 400 }
);
}
return Response.json(
{ error: "Internal error" }, { status: 500 }
);
}
}Language design
Correctness by construction
Every feature eliminates a category of bugs that AI generates in other languages. Not by convention — by design.
No null. No exceptions.
Option and Result types make invalid states unrepresentable. If it compiles, it handles every edge case.
One way to do everything
One syntax for iteration, one for error handling, one for binding. Zero ambiguity for AI and humans alike.
@schema auto-generation
Structs annotated with @schema auto-generate JSON serialization, validation, OpenAPI specs, and TypeScript types.
Structured concurrency
The parallel {} block is the only way to run concurrent code. No goroutine leaks. No data races. Predictable.
LANGUAGE_SPEC.md
A 3,000-token file gives any AI everything it needs. Paste into system prompt, .cursorrules, or Claude Projects.
AI-readable errors
Every compiler error includes machine-readable fix suggestions. AI self-corrects in one iteration, not three.
Native + JS targets
LLVM backend for servers and CLI. JS transpiler for Node.js. One language, backend and tooling.
Single binary toolchain
Compiler, formatter, linter, LSP, test runner, package manager — one binary, zero dependencies.
500-task benchmark
AI correctness rate
Percentage of tasks where AI-generated code compiles and produces correct output on the first attempt. Zero human edits.
Target metric. Baselines from internal AI model benchmarking.
Bug categories eliminated
| Error Category | Other Languages | Klar | How |
|---|---|---|---|
| Null / undefined | Very High | Impossible | No null in language |
| Unhandled exceptions | High | Impossible | Result type enforced |
| Type mismatches | High | Compile error | Full type inference |
| Wrong API pattern | Medium | Very Low | One canonical way |
| Serialization bugs | Medium | None | @schema auto-gen |
| Race conditions | Low-Med | Compile error | Structured concurrency |
Real benchmarks
Native speed. Zero compromise.
Klar compiles to native binaries via LLVM. Verified on Apple Silicon, best-of-5 runs.
Fibonacci
Recursive fib(40) — 204M+ function calls, pure compute
fn fib(n: Int) -> Int {
if n < 2 {
n
} else {
fib(n - 1) + fib(n - 2)
}
}
fn main() {
let result = fib(40)
println(result)
}Apple M-series · Klar native (LLVM O2) vs Node.js v20 · Best of 5 · Wall-clock
Token economics
Less code. Fewer errors. Greener compute.
Klar reduces total AI token consumption by 40% through four independent channels: shorter code, fewer error loops, smaller context, and amortized spec loading.
−40%
Token consumption
Fewer output tokens, fewer error loops, smaller context windows
$60K
Saved / 50 devs / year
vs. TypeScript on Claude Sonnet at medium usage
2x
Developer throughput
80-120% productivity gain from fewer error correction cycles
−13 kg
CO₂ per dev per year
Less GPU compute = less energy = less carbon
24-month plan
Roadmap
From proof of concept to production-ready ecosystem. Each phase has a clear exit gate.
Proof of Concept
Months 1-6
- Core language: types, enums, Option, Result, pattern matching
- JavaScript transpilation target
- klar build, klar run, klar test, klar fmt
- LANGUAGE_SPEC.md for AI tools
- 500-task correctness benchmark
Exit: 85%+ AI correctness on benchmark
Usable Language
Months 6-12
- LLVM native backend (x86_64, ARM64)
- Structured concurrency with async/await
- HTTP server, router, middleware
- Package manager with dependency resolution
- Full LSP for VS Code
Exit: Ship a real web API entirely in Klar
Production Backend
Months 12-18
- Database ORM with type-safe queries from @schema
- Migrations auto-generated from schema changes
- WebSocket support + real-time capabilities
- klar deploy to Fly.io and Docker
- Package registry + AI tool integrations
Exit: Production API with database deployed to cloud
Ecosystem Growth
Months 18-24
- Launch packages.klar.run registry
- Official AI tool integrations
- Enterprise monorepo support
- Interactive tutorial & cookbook
- Annual Klar Conf
Exit: 1,000+ stars, 100+ packages, stable 1.0