What is the best programming language for AI coding?

Claude Code wrote three programs in Go, Rust, Java, TypeScript and Python. I measured what they cost to write and how fast they run: Go and Rust tie.

Cover for What is the best programming language for AI coding?

To the question of which programming language is best for AI coding, my data give two answers: Go and Rust. They are the cheapest for the agent to write and they produce the fastest programs. Python is only cheap as long as the program does not have to run fast. I measured it by asking Claude Code for the same three programs in Go, Rust, Java, TypeScript and Python, three times each.

This is about AI-assisted coding, or vibe coding if you prefer that name: which language to pick when an agent writes the code. For training models the answer is still Python, and this article does not go there.

I came in with a thesis: Go sits in the sweet spot, because it is cheap for the agent to write, the program runs fast on little memory and the code reads well. The thesis holds with one correction. Go is not alone in that spot, and my data cannot separate it from Rust.

The claim going around is stronger than mine. In February, Burak Karakan titled a post “Go is the Best Language for AI Agents”, and in August the Google Developers Blog published “Why Go is an Ideal Language for AI-Assisted Software Engineering”. Their arguments are reasonable, such as static types acting as a safety net for agent-written code, or the promise that code written for Go 1.0 still compiles today. Neither brings a measurement. Karakan admits as much in his post, where he says agents give him valid Go in one shot 95% of the time and adds “I have absolutely no data whatsoever on this”.

To claim a language is the best for AI coding you have to compare it with others, so I set up the comparison with the same method as the Everything Claude Code test: fixed tasks, tests the agent never sees and several repetitions.

Three programs, five languages, one brief

All three tasks are single-file command-line programs. They read from standard input, write to standard output and may only use the standard library:

  • A log summary that reads up to three million lines of a web access log, drops the invalid ones, normalizes the paths and prints the ten with the most requests.
  • The cheapest path between two cells of a grid of up to 2,000 by 2,000, with walls.
  • An interpreter for a small assembly language, with eight registers, memory and jumps, that can run up to 200 million instructions.

Each session starts in a clean folder with the spec, the build and run commands, three example tests and the minimal skeleton for the language (go.mod, Cargo.toml, tsconfig.json). The brief only changes the name of the language. It was written in Spanish, and this is my translation:

Implement in Go the program described in SPEC.md, in this folder. Read LEEME.md first: it explains how to build, run and test it. Use only the standard library. Finish when python pruebas.py passes all the example tests.

I ran it with claude -p on Claude Code 2.1.332 with Opus 5.5, with no user settings, plugins or MCP servers. Three repetitions per task and language make 45 sessions, which add up to $10.91 at API prices.

For each session I recorded the agent’s cost, time and turns. For each program, whether it passes twelve hidden tests with edge cases that the agent never gets to see, how long it takes on a large input, how much memory it uses and how many lines it has. The large input is three million log lines, a 2,000 by 2,000 grid with four queries and a program of 119 million instructions. Each program ran it five times, one at a time.

Go and Rust end up in the same corner

All 45 programs pass the twelve hidden tests for their task. With programs this size no language made the model fail, so the comparison comes down to what they cost to write and how they run afterwards:

LanguageCost to writeSessionRun timeMemoryLines
Go$0.21338 s×1.07×2.03170
Rust$0.21938 s×1.01×1.69134
Java$0.23342 s×1.53×2.64131
TypeScript$0.24248 s×3.04×5.90125
Python$0.306110 s×13.3×3.98113

Cost is the average per session that Claude Code calculates at API prices. For run time and memory, ×1 is the best language on each task, and the figure in the table is the geometric mean of the three.

Scatter plot of the cost of writing each program against its run time. Go and Rust sit together at the bottom left, cheap and fast; Python sits at the top right.

Go is the cheapest to write and its programs come within 7% of the fastest. Rust costs 3% more and runs 6% faster, with less memory and fewer lines. The cost difference between the two is $0.007 per session. Pairing the sessions by task and repetition, Go comes out cheaper in five of the nine pairs, and the 95% interval (bootstrap) runs from −$0.005 to +$0.019, with zero inside it. I call that a tie.

Against Java and TypeScript, Go’s advantage is more consistent, because it comes out cheaper in seven and in eight of the nine pairs. We are still talking about two and three cents per session. And Go is only the cheapest in one of the three tasks, the interpreter. In the log summary Python and Rust beat it, and in the grid Java wins by two tenths of a cent. It takes the average because it never falls far behind the leader on any task.

Speed is where the gaps do not depend on nine sessions. Go and Rust run together, Java takes 1.5 times as long, TypeScript 3 times and Python 13.

The part of my thesis left unconfirmed is readability. I did not measure it, and the closest figure I have points the other way, because Go needs the most code to do the same job: about a quarter more than Rust and 50% more than Python.

Python is cheap until the program has to run fast

Python’s average cost hides two opposite behaviors, which show up when the tasks are split:

TaskGoRustJavaTypeScriptPython
Log summary$0.224$0.210$0.267$0.271$0.194
Grid$0.183$0.196$0.181$0.215$0.366
Interpreter$0.231$0.252$0.251$0.241$0.358

In the log summary, Python is the cheapest of the five, with a 58-line program against Go’s 186. In the other two tasks it is the most expensive by a wide margin. It costs twice as much as Go in the grid and 55% more in the interpreter, and its sessions average over two minutes while Go’s last 29 and 40 seconds.

Nobody asked the agent for a fast program. The spec gives the maximum sizes and the test script cuts each case off at 60 seconds. From those two facts, in Python the agent concludes that the straightforward version will not make it and starts optimizing. In the interpreter it solved it the same way all three times: it stopped interpreting and wrote a translator that turns the assembly into Python code and runs it with exec. This is how it justified it in one of the sessions (the reply was in Spanish; the translation is mine):

It is translated into a Python function that is then executed, because a normal interpreter in Python would not get through the 200 million instructions within the 60 s limit per test.

The translator emits one line of Python for each assembly instruction. This fragment is from one of the three versions:

if op == "set":
    out.append(f"{args[0]} = {operand(args[1])}")
elif op == "add":
    out.append(f"{args[0]} = ({args[0]} + {operand(args[1])}) % {M}")
elif op == "sub":
    out.append(f"{args[0]} = ({args[0]} - {operand(args[1])}) % {M}")

It is a clever solution and it still takes 3.57 seconds on the large input, 22 times longer than the Go version, which is a loop with a switch per instruction and takes 0.16. In the grid the agent looked for shortcuts too, and one of the three Python versions spreads the work across processes with ProcessPoolExecutor to use several cores. In Go, Rust and Java it writes the straightforward version, which is already fast, and finishes in about six turns and forty seconds.

That Python is the cheapest when the simple program is enough and the most expensive when it is not is something I saw in the data. The cause is my inference. To confirm that the extra cost comes from the performance requirement and not from the kind of problem, I would have to repeat the same tasks with small sizes, and I have not run that.

The same language gives different programs

The repetitions also show how much the program changes from one session to the next without changing language. In the log summary, two of the three Go versions load the whole input into memory and reach 384 MB, while the third reads it line by line and stays at 24 MB. In TypeScript, one version of the interpreter takes 0.35 seconds and the other two almost a second. The three Python versions of the grid range from 2.1 to 4.6 seconds.

In that log task, memory depends more on how the agent decided to read the input than on the language. That is why I do not trust the small differences in this benchmark, and I do trust the large ones.

What other benchmarks say

The most cited benchmark is Yusuke Endoh’s. In March he asked Claude Code with Opus 4.6 for a mini-git in thirteen languages, twenty times each. The cheapest were Ruby, Python and JavaScript, between $0.36 and $0.39 per run. Go and Java cost $0.50, Rust $0.54 and TypeScript $0.62. It agrees with mine in that Go, Rust and Java cost about the same, and in that Python is cheaper when the task is small. What it does not measure is the speed of the resulting program, which is what turns my ranking around. Endoh himself warns that he is a Ruby committer and asks readers to take his interpretations with a grain of salt.

On whether AI gets more right in one language than in another, my benchmark adds nothing, because it always gets it right. The published data on real projects go against Go. On 24 November, Evil Martians analyzed the results of SWE-bench Multilingual, 300 real issues from 41 repositories attempted by 13 models, and in their table Go is last of ten languages, with 53% solved against Rust’s 72% once task difficulty is evened out. They set the limit themselves, because no repository has tasks in more than one language and comparing languages also means comparing projects. In MirrorCode, where the agent rewrites 25 programs in six languages, the authors found “little sign of inter-language differences in solve rates, for any model”.

Dan Luu, who ran his own test with a Zstd decoder in 25 languages, sums it up: “Most of the claims that get thrown around about how a particular language is good for LLM use seem to be wrong”.

What this benchmark does not say

These are three small programs, a single file each, between 57 and 212 lines, with no external libraries. They say nothing about large projects, frameworks or maintaining existing code, which is where SWE-bench leaves Go in last place. Three repetitions per task and language are enough to see that Python runs thirteen times slower, but not to rank languages that are two cents apart.

I only tested Claude Code with Opus 5.5. With Codex, a replication of Endoh’s benchmark orders the costs differently and leaves Go more expensive than Rust, Java and TypeScript. Everything was measured on Windows 11 with each language’s defaults, and three sessions ran at once, which affects session time but not cost.

Which language I would pick for AI coding

For a program that will mostly be written by an agent and then has to run fast, I would choose between Go and Rust. My data do not decide between the two. I am sticking with Go, and that is a preference: a smaller language and faster compilation, the same reasons I would pick it with no AI involved, which I laid out in Go vs Rust.

For a script that runs once, or for gluing two services together, Python is still the cheapest thing to ask for, and its slowness does not matter there, as I argued in Go vs Python. Java and TypeScript sit in the middle. They cost the agent two and three cents more per session than Go, and their programs take 1.5 and 3 times as long as the fastest. I would not choose them because of AI, but I see no reason to drop them in a project that already uses them.

What I would rule out is choosing a language by what it costs the AI to write it. The gap between the cheapest and the fourth is three cents per session, while the slowest program takes thirteen times as long as the fastest, so what the program has to do afterwards weighs far more.

“Go is the best language for AI coding” is not something I can sign. That Go and Rust are the two that come out cheap to write and fast to run, I can, with three small programs and a single model.

OshyTech

Backend and data engineering focused on scalable systems, automation, and AI.

Navigation

Copyright 2026 OshyTech. All Rights Reserved