The Best Programming Language for AI Agents Isn't the One You'd Guess
“Which language should I learn?” For twenty years, the answer barely changed. The one that gets you hired. The one with the libraries. The one your team already uses. Then coding agents started shipping production code, and a variable nobody planned for slid into the equation: the language humans read best and the language models handle best are not the same language.
Let me be upfront — this isn’t a raging debate yet. Search the last month of Reddit and you’ll find almost nothing worth reading on it. But anyone who has actually run agents against a real codebase has felt the friction, and this argument is coming. So here’s an early attempt to think it through with the data and the structural logic we have.
Tokens Are Money, and Also Your Context Budget
What an agent does with code is simple. Read a file, edit it, read it again. Every one of those steps costs tokens. And tokens hit you two ways.
First, the literal invoice. If language A burns 40% more tokens than language B for the same feature, your agent bill is 40% higher for that project. Straightforward.
The second cost matters more. Context windows are finite. Even a 1M-token window shrinks fast when your codebase is verbose — fewer files fit in a single view. If a change requires reasoning across three files and only one fits, that’s not a budget problem. That’s an accuracy problem.
A common misread here: token efficiency is not line count. Tokenizers slice text into fragments. Identifiers that look like English words cost one or two tokens; long snake_case names and unusual symbol clusters shatter into many more. So yes, code can be shorter in lines and more expensive in tokens. Symbol-heavy languages walk into this trap constantly.
Verbosity Isn’t Always the Enemy
Here’s where it gets interesting. On raw token count, Python wins. Terse syntax, close to English, and an absolutely dominant share of the training data. It’s no accident that models look most comfortable writing Python.
But when an agent writes code, a counterforce kicks in. The agent’s real bottleneck isn’t generating code — it’s confirming the code is correct. A human carries the context in their head and can eyeball it. An agent has no such intuition. Compilers, type checkers, and tests fill that gap.
Seen that way, Rust’s verbosity looks less like a cost and more like an investment. Errors caught by the ownership model and type system are errors the agent doesn’t burn tokens flailing at during runtime. Rust’s compiler messages are, frankly, excellent feedback. Go’s advantage is different: the syntax surface is small, so the space of plausible code shapes is small. Fewer options, fewer wrong turns.
The shape of it: Python is cheap on the first attempt and expensive to verify. Rust is expensive on the first attempt and needs fewer retries. Go sits in the middle on both but with much tighter variance. Which one wins on total cost depends entirely on the kind of work.
The Real Metric Is Total Tokens Per Correct Change
Which is why “which language uses fewer tokens” is only half a question. The real one: how many total tokens did it take to land one feature correctly?
That has at least four components. Cost to read the code. Cost to write it. Number of verification loops. Cost to unwind a failure. The third one is the killer. If an agent takes three passes at the same bug, no amount of syntactic brevity survives.
And there’s a variable bigger than the language itself: toolchain quality. Are the error messages actually helpful? Is type information statically visible? Do tests finish in seconds? Does the formatter make output deterministic? Much of Rust and Go’s reputation for being agent-friendly comes from this layer, not from syntax. Flip it around: Python with real type hints, mypy, and ruff wired up is a genuinely different animal from Python without them.
So Should You Switch Languages?
Before jumping to a conclusion, a few counterarguments deserve airtime.
The strongest is training data asymmetry. Models learned from the code that exists, and that distribution leans hard toward Python and JavaScript. A language can be theoretically ideal for verification and still underperform in practice if the model doesn’t know its idioms. This is exactly why “our niche functional language has a powerful type system, therefore it’s optimal for agents” keeps failing to land in the real world.
Second: switching languages is not paid back by a few percent in token savings. Team expertise, library ecosystem, hiring pipeline, operational scar tissue — all of it is bound to your current stack. Agent costs trend down over time. Migration costs don’t.
What a working engineer can do right now isn’t a rewrite. It’s making the language you already use more agent-friendly. Add type hints. Turn the linter up. Make tests fast. Fix the error messages so they’re readable. Even just splitting oversized files into reasonable chunks measurably improves context efficiency.
Language Design Just Got a Second Audience
Step back and something stranger comes into view. Programming languages have always been designed for humans. Readable syntax, memorable keywords, intuitive abstractions. Now the entity reading and writing the most code might not be human.
If future language and standard library design starts scoring “tokenizer friendliness” or “APIs an agent is unlikely to misuse” as evaluation criteria, that will be a genuinely odd sight. Some frameworks already ship separate documentation written for agents to consume. The direction is visible.
There’s a trap, though. If you leave code that humans can’t read simply because agents handle it fine, one day something breaks and nobody can touch the codebase. Where to draw the line between agent optimization and human comprehensibility is something every team has to decide for itself.
The Takeaway
The criteria for choosing a language are shifting, but the answers aren’t settled. What’s clear is that a new axis exists — accuracy per total token — and on that axis, a strong verification loop beats terse syntax.
Start by checking whether your current codebase is kind to an agent. Are the types there? Do tests finish in seconds? Are the error messages worth reading? That’s a much faster path than tearing out your language.
Comments
Loading comments...