DEV Community

Gautam Kishore
Gautam Kishore

Posted on

KARN - Language agents speak

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Full Ecosystem Access

from pip numpy as np
from npm react as R
from cargo serde as serde
from sys ffmpeg as ff
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Built by the team at Eulogik. Thanks to everyone who made this possible!

Top comments (0)