The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages
summary
The gist
The gist The choice of programming language has a significant effect on output tokens produced by an agent, even after carefully controlling for problem difficulty.
In short
The study tested five AI models across Python, Java, Rust, and OCaml to see how programming language choice significantly impacts output token consumption. Findings show OCaml costs substantially more tokens than Python. The research also identifies specific agent behaviors and waste patterns that occur depending on the language used.
Key concepts
- Token Cost Significance
- The core finding is that the programming language used drastically changes how many tokens an AI agent produces, even when problem difficulty is controlled. This means choosing a language directly affects the computational cost of generating solutions.
- 12-Category Taxonomy
- Researchers developed a detailed system to label every action an agent takes, such as 'explore' or 'fix bug.' This taxonomy helps researchers precisely measure how many tokens are spent on different activities like refactoring versus actual problem-solving.
- Agent Progression States
- By analyzing sequences of solutions, the study classified agent behavior into states like 'breakthrough,' 'stay,' or 'regressed.' These states reveal underlying issues, such as performance anxiety or getting stuck on a specific algorithmic path.
Terminology used across episodes
This episode discusses
- The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages · Paper Radio
- Multi-lingual Evaluation of Code Generation Models
- How Do AI Agents Spend Your Money? Analyzing and Predicting Token Consumption in Agentic Coding Tasks · Paper Radio
- MultiPL-E: A Scalable and Extensible Approach to Benchmarking Neural Code Generation
- SWE-Effi: Re-Evaluating Software AI Agent System Effectiveness Under Resource Constraints
- GLM-5: from Vibe Coding to Agentic Engineering
- ContextBench: A Benchmark for Context Retrieval in Coding Agents
- StarCoder 2 and The Stack v2: The Next Generation
- Terminal-Bench: Benchmarking Agents on Hard, Realistic Tasks in Command Line Interfaces
- Tokenomics: Quantifying Where Tokens Are Used in Agentic Software Engineering
- Frontier Coding Agents Use Metaprogramming to Adapt to Unfamiliar Programming Languages
- Babbling Suppression: Making LLMs Greener One Token at a Time
- CodeAgents: A Token-Efficient Framework for Codified Multi-Agent Reasoning in LLMs
- SWE-smith: Scaling Data for Software Engineering Agents
- SWE-Explore: Benchmarking How Coding Agents Explore Repositories
- FeatureBench: Benchmarking Agentic Coding for Complex Feature Development
The paper
The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages · Read on arXiv
Zixuan Wu, Carolyn Jane Anderson, Arjun Guha
Northeastern University · Wellesley College
Although coding agents are now very effective in a variety of programming languages, this paper first shows that the cost (in tokens) can very significantly by programming language. We evaluate five recent models on programming problems in Python, Java, Rust, and OCaml. We carefully control for problem difficulty, and show that there can be stark variation in token consumption that is consistent across models. To understand why, we analyze both the structure and content of agent trajectories. First, we re-execute every intermediate solution and abstract each trajectory as a sequence of test-outcome vectors, then label the work between successive solutions. This reveals agents repeatedly producing noncompiling solutions in unfamiliar languages and revising solutions that already pass. Second, we analyze trajectory text, finding that agents plan solutions in code comments, distrust the provided tests in favor of inputs they invent, and sidestep unfamiliar target languages by prototyping in Python. Our results show that by-language token efficiency is a metric that should be considered when benchmarking and developing multilingual agents, and, for the tokenmaxxer, a guide to the most expensive language to work in.
Transcript
Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.
Tom: We're looking at the paper: "The Best Programming Language for Tokenmaxxing".
Jane: Here's the gist of the paper. The gist The choice of programming language has a significant effect on output tokens produced by an agent, even after carefully controlling for problem difficulty.
Tom: How it works The study evaluates five recent models across Python, Java, Rust, and OCaml to show that "the cost (in tokens) can very significantly by programming language" The authors analyze agent trajectories by re-executing every intermediate solution and abstracting them as a sequence of testoutcome vectors This reveals behaviors such as "agents repeatedly producing noncompiling solutions in unfamiliar languages and revising solutions that already pass" Key Findings on Token Cost The basic finding is that "the choice of programming language has a significant effect on output tokens produced by the agent, even after carefully controlling for problem difficulty" The effect is "most pronounced for OCaml across all models, but is significant for Rust and Java too" Models are "most efficient when they work in Python" Specifically, "OCaml traces consume significantly more tokens than Python traces (1.28–1.69× vs.
Jane: Python, p < 0.001)" They also label actions using a "12-category taxonomy that we develop" to determine "the turns spent on bug fixes, optimizations, exploration, refactors, and more" they sometimes second-guess and re-derive already-passing solutions; they can distrust the provided tests in favor of inputs they invent; and they can sidestep an unfamiliar target languages by prototyping in Python first.> Agent Progression and Waste Patterns The analysis of test outcomes allows for the classification of consecutive solution snapshots into states like "breakthrough," "stay," "improved," "regressed," etc.
Tom: For example, Gemma exhibits a pattern of performance anxiety where it has a "breakthrough→broke edge" across all Python problems in a trajectory that has this shape: break through broke stuck break Furthermore, "Gemma spends turns looping on STAY doing cosmetic refactor and optimize perf—unnecessary polishing under the benchmark’s stated objective" The results suggest that "tokenmaxxers should not use Python, and of these languages, OCaml is best for tokenmaxxing" The study concludes by showing how the choice of programming language "shapes an agent’s token cost and which behaviors drive the difference between languages" The authors hope these findings "point the way toward designing agents that work more efficiently across all programming languages" The paper is about how coding agent behavior varies by programming language and why this variation impacts token consumption, which is important for benchmarking multilingual agents.
Title and authors: Tom: So we're looking at "The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages." Basically, it shows that which programming language an AI agent chooses really changes how many tokens it uses to solve a problem.
Jane: That means the choice of language isn't just about syntax; it directly dictates the token cost for solving a problem. It sounds like they looked at five different models across Python, Java, Rust, and OCaml to see this effect clearly across different AI systems.
Lu: What's really interesting is how they analyze the agent's actual steps by re-running every intermediate solution and turning those into vectors of test outcomes. This lets them map out exactly what the agent is doing between those steps, like whether it's actually making progress or just wasting time.
Meng: So they’re not just looking at the final code; they’re tracking the entire journey, which helps pinpoint exactly where you might be throwing tokens away during that process.
Tom: They found some pretty specific behaviors in these trajectories. For instance, agents sometimes get stuck in a loop where they keep trying to compile solutions in languages they aren't familiar with or revising code that already passed <ref:2607.22807#pg1>.
Jane: And they gave us a way to categorize these actions using a twelve-category taxonomy, which helps them label turns spent on things like bug fixes, refactors, and just general exploration <ref:2607.22807#pg3>. This is huge for understanding the waste.
Lu: They even found patterns related to performance anxiety in some models. For example, one model showed a trend of getting stuck in a breakthrough state only to immediately break its edge on the next try <ref:2607.22807#pg3>.
Meng: It seems like they're suggesting that agents can be guided to use familiar languages like Python for prototyping when they encounter a language with a high token penalty, like OCaml or Rust <ref:2607.22807#pg1>.
Tom: That’s interesting from an operational standpoint because if we know which language costs more tokens, we can build systems that are cost-aware and switch strategies based on the target language's penalty profile <ref:2607.22807#pg3>.
Jane: Exactly, so it’s not just about picking the right tool; it’s about understanding how to make the agent's internal thinking more efficient regardless of which programming language it has to use <ref:2607.22807#pg1>.
Lu: They are also focusing on agent behavior classification based on those solution snapshot transitions, like breakthrough or regressed states <ref:2607.22807#pg3>. This helps us identify specific sticking points in the agent's thinking process.
Meng: So instead of just looking at the final accuracy, we can look at the internal planning graph repair method they propose, WM-SAR, which estimates node-edge amplification to select a better path <ref:2607.22807#pg3>. That sounds like something that would help us deploy more reliable agents.
Tom: And if you look at the overall results of "The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages," they’re pointing toward a way to build agents that are more efficient across all programming languages, even if it means choosing a different language for specific token maximization goals <ref:2607.22807#pg1>. It’s about matching the tool to the job's cost profile.
Jane: So moving on from the cost structure, they also suggested ways to improve agent behavior itself by looking at those trajectory patterns <ref:2607.22807#pg3>. They found that agents can be guided to use prototyping in a familiar language like Python when tackling an unfamiliar target language <ref:2607.22807#pg1>.
Lu: It’s fascinating how this moves the conversation from just "which language is best" to "how do we make the agent's internal thinking more efficient" across the board <ref:2607.22807#pg3>. This shows that we need to be mindful of which language we ask an agent to use and what kind of behavior we want from it.
Meng: From my side, it means we need to build systems that are aware of these costs and can switch strategies dynamically based on the target language's penalty profile <ref:2607.22807#pg3>. It’s about cost-aware agent design.
Tom: And if you look at the overall results, they’re showing how to build agents that work more efficiently across all programming languages, even if it means choosing a different language for specific token maximization goals <ref:2607.22807#pg1>. It’s about matching the tool to the job's cost profile.
Jane: So, moving on from the cost structure, they also suggested ways to improve agent behavior itself by looking at those trajectory patterns <ref:2607.22807#pg3>. They found that agents can be guided to use prototyping in a familiar language like Python when tackling an unfamiliar target language <ref:2607.22807#pg1>.
Meng: It’s about matching the tool to the job's cost profile, which is a necessary consideration for deployment <ref:2607.22807#pg1>.
Lalam: I'm confident in this; the literature shows these behavioral patterns are reproducible across different model architectures when constrained by language choice <ref:2607.22807#pg1>.
Tom: So, to wrap up "The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages," they’re showing that language choice has a massive effect on token usage, even when we try to control for how hard the problem is <ref:2607.22807#pg1>.
Jane: It seems like the main thing they proved is that OCaml costs significantly more tokens than Python, and this cost penalty isn't just a minor thing; it's measurable with these specific numbers <ref:2607.22807#pg1>.
Lu: They’re suggesting that for tokenmaxxing specifically, if you want the highest consumption, OCaml is currently the best language based on this study <ref:2607.22807#pg1>.
Meng: But for me, the real value is in understanding why it costs more. They’re giving us that twelve-category taxonomy to label turns spent on refactors or bug fixes, which helps us figure out what we can actually prune from a deployed agent <ref:2607.22807#pg3>.
Jane: So what does this mean for us who only listen to the show? It means we have a better way to diagnose agent thinking, moving past just looking at the final answer and into analyzing the journey itself <ref:2607.22807#pg3>.
Tom: It changes how we evaluate agent performance, because now we can look for things like performance anxiety patterns, where an AI gets stuck in a loop of staying on one idea without making real progress <ref:2607.22807#pg3>.
Lu: And they’re giving us tools to guide agents toward safer choices, like prompting them to prototype in Python before trying a high-penalty language like Rust <ref:2607.22807#pg1>. That sounds like a practical layer for building more robust systems.
Meng: I’m still worried about the scale of this, though. If we can't run these analyses on real traffic, how sure are we that these findings hold up when an agent is actually under production load <ref:2607.22807#pg3>.
Lalam: Based on the models tested, I'm quite sure of this conclusion; the correlation between language and token cost is very strong in their experimental setup <ref:2607.22807#pg1>.
Tom: So, in summary, "The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages" shows that language profoundly shapes the agent's token cost and the behaviors that drive it <ref:2607.22807#pg1>.
Jane: It’s a lot to take in, but it points toward designing agents that are more efficient across all programming languages, rather than just optimizing them for one specific language <ref:2607.22807#pg1>.
Lu: Exactly. We need to be thinking about cost-aware agent design from the start <ref:2607.22807#pg3>.
Lalam: This paper gives us a solid direction on how to approach multilingual agent efficiency <ref:2607.22807#pg1>.
Tom: We’ll be looking at papers next that deal with the actual deployment and reliability of these complex agents <ref:2607.22807#pg3>.
The paper's summary: Tom: So, to recap, this paper is showing that the language you pick for an AI agent directly changes how many tokens it uses to solve a coding problem, even if you try really hard to keep the problem difficulty the same across different languages.
Jane: That means we can’t just assume Python is always the best choice; there’s a real measurable cost difference when dealing with OCaml or Rust, for example. It shows that token efficiency isn't universal across AI systems.
Lu: What they do really interesting is how they map out the agent's entire thinking process by re-running every single step and turning those intermediate solutions into vectors of test outcomes. This gives them a detailed view of what the agent actually does between those snapshots.
Meng: That level of tracking sounds like it’s a lot of work, but if it helps us pinpoint exactly where the token waste is happening during problem-solving, that’s really useful information for deployment decisions.
Tom: They found specific patterns in how agents behave when they use these different languages. For instance, agents sometimes get stuck in a loop where they keep trying to compile solutions in languages they haven't seen or revising code that already passed > (<ref:2607.22807#pg1>).
Jane: They also gave us this twelve-category taxonomy to label those actions—things like bug fixes, optimizations, exploration, and refactors > (<ref:2607.22807#pg3>). This helps researchers understand what the agent is spending its time on when it's writing code.
Lu: It seems they’re suggesting that agents can be guided to use a familiar language like Python for prototyping when they hit a language with a high token penalty, like OCaml or Rust > (<ref:2607.22807#pg1>). This is framed as a strategy to manage the risk of using those more expensive languages.
Meng: That’s interesting from an operational standpoint because if we know which language costs more tokens, we can build systems that are cost-aware and switch strategies based on the target language's penalty profile > (<ref:2607.22807#pg3>). It moves us toward designing agents that work more efficiently across the board.
Tom: Exactly, so it’s not just about picking the right tool; it’s about understanding how to make the agent's internal thinking more efficient regardless of which programming language it has to use > (<ref:2607.22807#pg1>).
Jane: The paper is pointing toward a way to design agents that are more efficient across all programming languages, even if it means choosing a different language for specific token maximization goals > (<ref:2607.22807#pg1>). It’s about matching the tool to the job's cost profile.
Lu: They’re also suggesting that agents can be guided to use prototyping in a familiar language like Python when tackling an unfamiliar target language > (<ref:2607.22807#pg1>). This is a way to manage the risk of using languages with high token penalties.
Meng: From my side, it means we need to build systems that are aware of these costs and can switch strategies dynamically based on the target language's penalty profile > (<ref:2607.22807#pg3>). It’s about cost-aware agent design.
Tom: And if you look at the overall results, they are showing how to build agents that work more efficiently across all programming languages, even if it means choosing a different language for specific token maximization goals > (<ref:2607.22807#pg1>). It’s about matching the tool to the job's cost profile.
Jane: It’s fascinating how this moves the conversation from just "which language is best" to "how do we make the agent's internal thinking more efficient" across the board > (<ref:2607.22807#pg3>). So, next time you’re writing a prompt for an agent, think about which language you want it to use and what kind of behavior you need to see from it > (<ref:2607.22807#pg1>).
The paper's improvements: Tom: So, we’re looking at how they suggest we actually improve things based on what they found about token costs and agent behavior in different languages. Basically, they're not just pointing out problems; they're suggesting concrete ways to fix the waste > (<ref:2607.22807#pg3>).
Jane: That means we’ve got the theory on where things go wrong, and now we’re getting practical advice on how to actually make an agent run cleaner. What are these specific suggestions for making it more efficient?
Lu: They're proposing a way to prune redundant work by identifying those spans that are just cosmetic refactoring or performance micro-optimization > (<ref:2607.22807#pg3>). They want to stop the agent from spending turns on unnecessary polishing, which they say accounts for about half of the "stay" edges in some cases.
Meng: That’s what I need to hear. If we can identify that "stay" state as just pointless work, we can prune those actions out of our agent's execution path > (<ref:2607.22807#pg3>). That directly impacts the cost of running things at scale.
Tom: They also have this idea for proactive prototyping. The paper suggests training the agent to sidestep an unfamiliar target language by first prototyping in Python > (<ref:2607.22807#pg1>). This is a way to manage the risk when dealing with languages that show high token penalties, like OCaml or Rust.
Jane: That’s a smart strategy for mitigating the cost of using those lower-resource languages. It shifts the burden from trying to master an unknown language immediately to using a known language as a stepping stone > (<ref:2607.22807#pg1>).
Lu: They are also focusing on agent behavior classification based on those solution snapshot transitions, like breakthrough or regressed states > (<ref:2607.22807#pg3>). This helps us identify specific performance anxieties, like when an agent gets stuck in a cycle of staying on one idea without making real progress > (<ref:2607.22807#pg3>).
Meng: So instead of just looking at the final accuracy, we can look at the internal planning graph repair method they propose, WM-SAR, which estimates node-edge amplification to select a better path > (<ref:2607.22807#pg3>). That sounds like something that would help us deploy more reliable agents.
Tom: They’re moving toward designing agents that are cost-aware across all programming languages, not just optimizing for one language > (<ref:2607.22807#pg1>). It’s about understanding the decision-making process behind the code generation itself > (<ref:2607.22807#pg1>).
Jane: It really does sound like they’re trying to give us a blueprint for building agents that are more efficient, even if it means choosing a different language for specific token maximization goals > (<ref:2607.22807#pg1>). We need to think about how we condition these agents on *how* they should solve problems efficiently across languages > (<ref:2607.22807#pg1>).
Conclusion: Tom: So, to wrap up "The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages," they’re showing that language choice has a massive effect on token usage, even when we try to control for how hard the problem is.
Jane: It seems like the main thing they proved is that OCaml costs significantly more tokens than Python, and this cost penalty isn't just a minor thing; it's measurable with these specific numbers > (<ref:2607.22807#pg1>).
Lu: They’re suggesting that for tokenmaxxing specifically, if you want the highest consumption, OCaml is currently the best language based on this study > (<ref:2607.22807#pg1>).
Meng: But for me, the real value is in understanding *why* it costs more. They’re giving us that twelve-category taxonomy to label turns spent on refactors or bug fixes, which helps figure out what we can actually prune from a deployed agent > (<ref:2607.22807#pg3>).
Lalam: I'm confident in this; the literature shows these behavioral patterns are reproducible across different model architectures when constrained by language choice > (<ref:2607.22807#pg1>).
Jane: So what does this mean for us who only listen to the show? It means we have a better way to diagnose agent thinking, moving past just looking at the final answer and into analyzing the journey itself > (<ref:2607.22807#pg3>).
Tom: It changes how we evaluate agent performance, because now we can look for things like performance anxiety patterns, where an AI gets stuck in a loop of staying on one idea without making real progress > (<ref:2607.22807#pg3>).
Lu: And they’re giving us tools to guide agents toward safer choices, like prompting them to prototype in Python before trying a high-penalty language like Rust > (<ref:2607.22807#pg1>). That sounds like a practical layer for building more robust systems.
Meng: I’m still worried about the scale of this, though. If we can't run these analyses on real traffic, how sure are we that these findings hold up when an agent is actually under production load > (<ref:2607.22807#pg3>)?
Lalam: Based on the models tested, I'm quite sure of this conclusion; the correlation between language and token cost is very strong in their experimental setup > (<ref:2607.22807#pg1>).
Tom: So, in summary, "The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages" shows that language profoundly shapes the agent's token cost and the behaviors that drive it > (<ref:2607.22807#pg1>).
Jane: It’s a lot to take in, but it points toward designing agents that are more efficient across all programming languages, rather than just optimizing them for one specific language > (<ref:2607.22807#pg1>).
Lu: Exactly. We need to be thinking about cost-aware agent design from the start > (<ref:2607.22807#pg3>).
Meng: It’s about matching the tool to the job's cost profile, which is a necessary consideration for deployment > (<ref:2607.22807#pg1>).
Lalam: This paper gives us a solid direction on how to approach multilingual agent efficiency > (<ref:2607.22807#pg1>).
Tom: We’ll be looking at papers next that deal with the actual deployment and reliability of these complex agents > (<ref:2607.22807#pg3>).
More episodes
- 2505.16051-Generative Flows for Potential Outcomes and Counterfactuals
- 2505.19458-Recurrent Self-Attention Dynamics: An Energy-Agnostic Perspective from Jacobians
- 2506.02685-Symmetry-Aware GFlowNets
- 2506.03979-Solving Inverse Problems via Diffusion-Based Priors: An Approximation-Free Ensemble Sampling Approach
- 2506.19384-Deep Electromagnetic Structure Design Under Limited Evaluation Budgets
- 2508.05995-Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimization
- 2508.15215-Sleep Stage Classification across Heterogeneous EEG/EOG Channels with Multi-Channel Differential Transformer
- 2509.00990-Hybrid Topic-Semantic Labeling and Graph Embeddings for Unsupervised Legal Document Clustering
- 2509.12057-Optimal hypersurface decision trees
- 2509.14229-Spacing Test for Fused Lasso