AI Code Generation Is Not Language-Neutral: 56% of Rust Errors Caught, 0% of Python
Quick answer: AI code generation accuracy is not a single number — it is a property of the model and the language's toolchain. In a 2026 study that ran one model through six language setups, Rust's compiler caught 56% of its wrong first attempts, Java's caught 45%, TypeScript's 10%, and Python's and JavaScript's caught none for a semantic reason. The language you generate into sets your error floor and your token bill before the model writes a line.
Every AI coding benchmark you read this year was probably Python: SWE-bench Verified, HumanEval, the demo that convinced your CTO. Your repository is TypeScript at the edge, Java in the services, Go in the platform team and a Rust component someone is very proud of.
That mismatch is not a marketing problem. It changes what a green build means, how many tokens a task really costs, and whether "the agent finished it" is a sentence you can repeat to your manager.
How accurate is AI code generation by language?
The best public answer comes from a November 2026 study by 23N AI Labs. It took 152 HumanEval tasks, ran one small local model through six language setups at temperature 0, and asked a narrower question than "which language wins": when the model's first attempt is wrong, does the toolchain notice?
| Language | Wrong first attempts flagged | Caught for a semantic reason | Semantic catch rate (95% CI) |
|---|---|---|---|
| Rust | 53/95 | 53 | 56% (46–65%) |
| Java | 36/77 | 35 | 45% (35–57%) |
| Go | 68/103 | 27 | 26% (19–35%) |
| TypeScript | 60/96 | 10 | 10% (6–18%) |
| Python | 3/63 | 0 | 0% (0–6%) |
| JavaScript | 3/66 | 0 | 0% (0–6%) |
Read the third column, not the first. The first counts every rejection, including ones a real project never sees: Go's 68 are mostly missing imports that goimports adds automatically; TypeScript's 60 are mostly syntax errors from the model running past the function. What survives your CI is this: a borrow checker is a correctness gate; a JavaScript interpreter is not.
What the checker can actually see
A compiler catches the class of mistake its type system was built to express. Rust caught type mismatches (E0308), missing trait implementations (E0277), unknown methods (E0599) and use-after-move (E0382) — errors that cannot reach production because they cannot compile. Java caught unknown symbols and long/int mismatches. Python's interpreter caught nothing semantic, because nothing in a plain python file.py run checks a type.
This is the part most "AI writes bad code" arguments miss. The model's error rate may be identical across languages; the detection rate is not. Both wrong functions leave the model at the same rate. Only one is stopped.
The 15% ceiling that keeps this honest
Before you conclude that Rust is the safe language for AI generation, look at what static checking is worth in general. Gao, Bird and Barr measured it in ICSE 2017: TypeScript and Flow each detect 15% of public JavaScript bugs. Fifteen percent of bugs that had already survived testing and code review.
And the 23N study's trust test is blunter. Even the strictest toolchains accepted 49–54 wrong programs out of 152, and a green build was correct only 55–66% of the time. Five percentage points of extra safety from a checker that catches half the semantic errors, because half of very little is still little.
So the honest claim is narrower than the headline: the language sets how much of your AI's error rate is even visible. It does not set whether the code is right.
One more caveat, because the numbers are quotable: this is one small model on 152 HumanEval tasks at temperature 0, on short functions where type systems have the least to check. The authors say explicitly it is not a ranking of languages, and a frontier model repairs Rust far better than a 1.5B one did. What generalises is the mechanism — the checker's reach — not the percentages.
Why does the same model write worse code in another language?
Because "the model" is a distribution over training data, and that data is not spread evenly. Multi-LCB, published at ICLR 2026, makes this measurable: it extends LiveCodeBench to 12 languages across 24 LLMs, holding the task and the judge fixed and varying only the language. The findings are what you would expect if you have watched a model write beautiful Python and mediocre Kotlin: Python overfitting, language-specific contamination, and large disparities on identical problems.
Popularity is a data argument, not a quality argument
The ranking of "which language does AI write best" tracks how much public code exists in it, which is why JavaScript and Python dominate and a niche DSL behaves like an untrained model. That is training volume, not difficulty for humans — and it changes as models are retrained, so treat last quarter's ranking as stale.
What does per-language accuracy cost per task?
The same study measured output tokens per accepted-and-correct task:
| Language | Output tokens per accepted, correct task |
|---|---|
| Python | 100 |
| Python + mypy | 114 |
| JavaScript | 124 |
| TypeScript | 140 |
| Java | 329 |
| Rust | 410 |
| Go | 561 |
A 5.6× spread between the cheapest and most expensive language for identical task difficulty. Partly verbosity — Java and Go say more per line — and partly repair: when a first attempt fails, the model gets diagnostics and tries again, which multiplied total output 2.4–3.2× for Java, Go and Rust.
Strictness is not productivity
Rust is the sharpest illustration, and it cuts against the article you expected. Its compiler caught more than any other toolchain — and 63 of 96 Rust repair attempts came back byte-identical to the attempt that had just failed. Only 10 of 53 rejections became green builds; 43 tasks ended still rejected.
The authors' sentence deserves quoting: "a strict compiler that the model cannot satisfy turns would-be wrong answers into no answers. That is honest, but it is not productive."
A gate that refuses everything is not quality control; it is a stoppage. If your Rust agent's throughput collapsed while its builds stayed clean, that is the likely reason, and the fix is model capability, not a looser gate. Cost per solved task survives this, which is why it is still the right unit.
Why do benchmarks overstate your language's score?
Because the benchmark is Python and your code is not. SWE-bench Verified is Python-only. SWE-bench Multilingual — 300 tasks, 42 repositories, 9 languages — showed the gap at launch: Claude 3.7 Sonnet resolved 43% on multilingual versus 63% on Verified, a ~20-point drop its authors attributed to "room for improvement in languages other than Python".
The gap is closing at the top: the November 2026 leaderboard has Claude Opus 4.6 at 72.0%, median 67.0%. But 72% is an aggregate over nine languages, and your language is not the average.
Repository scale is the number that matches your job
Granularity matters as much as language. PolyCodeEval (2,590 tasks from 58 real repositories, five languages) found the best methods produced correct output for 71.7% of functions, 76.7% of files, and 31.0% of repositories, with rankings shifting by both.
Almost every "the agent solved it" claim you read is function-level. Almost every ticket you file is repository-level. The distance between 77% and 31% is where your review time goes — the same weak-link effect the productivity data shows, where commit output rises but shipments barely move.
What is a per-language acceptance gate?
A gate is one contract applied to every language: the patch is accepted only if the checker passes and the tests pass. It is deliberately dumb, it takes an afternoon, and it converts "the agent said it's done" into an exit code.
// gate.mjs — one acceptance gate, six languages, one contract.
// node gate.mjs <lang>; exit 0 = accept, 1 = reject.
import { execSync } from 'node:child_process';
const LANGS = {
python: { check: 'python -m mypy --strict .', test: 'python -m pytest -q' },
typescript: { check: 'npx tsc --noEmit', test: 'npm test --silent' },
javascript: { check: null, test: 'npm test --silent' },
java: { check: './gradlew compileJava', test: './gradlew test' },
go: { check: 'go vet ./...', test: 'go test ./...' },
rust: { check: 'cargo clippy --all-targets -- -D warnings', test: 'cargo test --quiet' },
};
const run = (cmd) => {
if (!cmd) return { ok: true, note: 'no checker in this language' };
try { execSync(cmd, { stdio: 'pipe' }); return { ok: true }; }
catch (e) { return { ok: false, tail: String(e.stdout ?? '').slice(-600) }; }
};
const cfg = LANGS[process.argv[2]];
if (!cfg) { console.error('usage: node gate.mjs <lang>'); process.exit(2); }
const check = run(cfg.check);
const test = run(cfg.test);
const accepted = check.ok && test.ok;
console.log(JSON.stringify({ lang: process.argv[2], check, test, accepted }, null, 2));
process.exit(accepted ? 0 : 1);The JavaScript row is the honest one: check: null. There is no checker, and the note says so instead of pretending the test suite is one.
Where the gate belongs
Before review, not after merge. The check runs on the agent's diff in the job that would otherwise run the suite, and a non-zero exit returns the task with the diagnostics — the repair loop the study measured. Keep the checker's output in the task log so a rejection is diagnosable. Why a passing suite is a weak oracle is the argument here.
Where AutoCoder fits
AutoCoder is a Windows desktop app that runs on your own Claude or DeepSeek key. Five agents — Discoverer, Planner, Executor, Verifier and Reviewer — work a ticket end to end on your machine, then hand back the diff and the exact token cost of the run.
That is why this article is not abstract for us. Verifier is a stage, not a promise: your project's gate is where the language's checker gets its say, and the per-run token figure makes the 5.6× spread visible instead of theoretical.
Try AutoCoder free — fifty queries a month, no card, on the model key you already have: download it and sign up inside the app. The Windows-only detail and pricing are on the pricing page; if you are choosing between providers, the DeepSeek guide covers the routing trade-off.
What should you do this week?
- Measure in your language, not theirs. Run 50 real tickets from your tracker through your agent in your most common language, and record accepted-and-correct — not accepted.
- Add the gate before you add models.
check && testsin CI, on the agent's diff, with the diagnostic returned to the agent. - Record tokens per accepted-and-correct task. One column, same sheet. It is the only cost number comparable across languages.
- Re-benchmark quarterly. The multilingual gap is closing; a routing decision based on August numbers is wrong by November.
- Route by language. If Rust's gate rejects what the model cannot fix, send Rust to your strongest model and let the cheap one take Python and JavaScript, where the checker is not doing the work anyway.
Try AutoCoder free — run the gate on one repository this week and compare the diff to what you get without it: get the app.
FAQ
Which language is AI code generation most accurate in?
There is no stable ranking. What is stable is the detection rate: in the 2026 23N study, Rust's toolchain caught 56% of wrong first attempts for a semantic reason, Java 45%, Go 26%, TypeScript 10%, and Python and JavaScript none. Multi-LCB shows the same task in 12 languages producing materially different results across 24 models.
Does a type checker make AI-generated code correct?
No. TypeScript and Flow detect about 15% of public JavaScript bugs, and even the strictest toolchain in the 2026 study accepted 49–54 wrong programs out of 152, with a green build correct only 55–66% of the time. A checker proves the program is well-formed; tests prove it does the right thing.
Is Python worse than Rust for AI code generation?
Not in correctness per token — Python is the cheapest language measured, at 100 output tokens per accepted-and-correct task against Rust's 410. It is worse in visibility: a Python mistake usually reaches review undetected, while a Rust ownership error cannot compile.
How do I measure AI code accuracy in my own language?
Run 50 real tickets from your tracker through the agent, then count three things: how many the gate rejected, how many were accepted and correct, and the output tokens per accepted-and-correct task. Fifty is enough to see a 20-point difference and small enough to run this week.
Do more tokens buy more correct code?
Not reliably. The 5.6× token spread came with no correctness advantage for the expensive languages — Rust spent the most per correct task and left 43 rejected. Repair rounds multiply output 2.4–3.2×, and when the model cannot use the diagnostics the extra tokens buy the same wrong answer.
Related reading
The Containment Stack: The Three 2026–2028 AI Skills That Make Agent Output Safe to Run
The AI wage premium is now 62%, but it is not paid for calling a model. It is paid for being answerable for what the model does. Three skills produce that answer: execution isolation, OpenTelemetry GenAI telemetry, and deterministic replay. Here is the evidence, the tools and a shipping roadmap for each.
The Metered Three: The 2026–2028 AI Skills That Decide What Your Tokens Cost and Whether They're Correct
Four earlier posts on this site named eighteen skills that sit in front of the model. None covered the three seams where an LLM product actually bleeds: the prefix it re-reads on every turn, the contract its output must satisfy, and the route the request travels. Here they are, with the failure modes, the 2026 pay evidence, roadmaps and starting prompts.
Advanced RAG Architectures in 2026: Agentic, Multi-hop and GraphRAG Pipelines
Flat vector RAG breaks on multi-hop questions and global summaries. This guide walks through the agentic and graph-based architectures that research has validated since 2024, with the trade-offs and the evaluation you need before shipping.