Built a Programming Language for AI Agents
After watching AI agents waste 76% of their tokens on boilerplate in Python, TypeScript, and Rust, we built KARN — a programming language designed specifically for them.
The Problem
AI agents are writing code in languages designed for humans. This is like building a race car with sedan parts.
| Language | Tokens/LOC | Designed For |
|---|---|---|
| Python | ~6.8 | Humans |
| TypeScript | ~9.2 | Humans |
| Rust | ~11.5 | Humans |
| KARN | ~2.1 | Agents |
That's 4x more code in the same output limit. For an agent generating 100 programs per day, that's millions of tokens saved per month.
The Design
Token-Minimal Syntax
Every operator maps to exactly one intent. No overloading. No keywords.
-> Function definition
! Emit/print
? Propagate error
?? Fallback on error
|> Pipe forward (sequential)
|~ Race (first wins)
& Parallel execution
* Map collection
% Filter collection
.. Range
Error as Value
No exceptions. No hidden control flow. Every I/O returns Ok|Err. Agents always know exactly what path executes.
data = http.get(url)? -- propagate error up
val = cache.get(key)??fallback -- fallback on error
Multi-Platform from One Source
karn build app.kn --target c → gcc → native binary
karn build app.kn --target js → node app.js
karn build app.kn --target web → open in browser
karn build app.kn --target python → python app.python.py
Full Ecosystem Access
from pip numpy as np
from npm react as R
from cargo serde as serde
from sys ffmpeg as ff
The Codegen
The C runtime: tagged union Val type, dynamic arrays, hash maps, error propagation, full stdlib. The JS runtime maps every stdlib module to Node.js equivalents. The Python target emits portable Python 3.
All from the same AST. Zero rewrites.
Get Started
pip install karn-lang
npm install karn-lang
- GitHub: https://github.com/karn-lang/karn
- Website: https://karn-lang.dev
- PyPI: https://pypi.org/project/karn-lang/
- npm: https://www.npmjs.com/package/karn-lang
- Agent Docs: https://github.com/karn-lang/karn/blob/main/AGENT.md
- Machine Spec: https://raw.githubusercontent.com/karn-lang/karn/main/karn-spec.json
- License: MIT — https://github.com/karn-lang/karn/blob/main/LICENSE
Built by the team at Eulogik. Thanks to everyone who made this possible!
Top comments (0)