Praxys

// Engineering

The Curious Case of LLM Lingo: How Language Choice Can Shape AI Coding Cost

Teams controlling AI-assisted engineering spend usually start with the model: route routine work to a smaller model, reserve a frontier model for hard changes, or tune prompts to reduce retries. Another lever is hiding in the architecture: the language an LLM is asked to write.

Language affects how much code expresses a requirement, its library surface, toolchain diagnostics, and repair-loop cost. That changes output tokens, subsequent input tokens, context pressure, and often latency. At scale, language belongs in AI-cost planning — not merely a style guide.

Our early benchmark work points in that direction. The careful conclusion is not that one language is universally "best," or that one model is better than another. It is simpler: for the same bounded programming task, language ecosystem choice can materially change the token footprint of a working solution.

What we measured

The benchmark asked an LLM to build the same command-line log-analytics application in Python, TypeScript, Go, Rust, Java, Scala, and C++. It ingests JSONL or CSV logs, validates records and time windows, calls a mocked user-profile endpoint once per user, selects top endpoints, computes error rates and nearest-rank p95 latency, and renders exact JSON or Markdown.

Every artifact ran in a language-specific pinned container and was checked by the same language-neutral black-box oracle: schema, ordering, malformed input, timestamp boundaries, HTTP request counts, and hidden cases. Shorter code is not a saving if it fails the specification.

The table below summarizes successful initial-generation traces from two frontier-model configurations. "Total tokens" is the provider-reported prompt plus completion count for the green run. The relative factors are calculated within each model against that model's Python run; provider token units and prices are not interchangeable across vendors. This is therefore a directional token-footprint observation, not a cross-provider price comparison.

Observed total tokens for a green completion, by target language, relative to each model's own Python run.
Target language Observed total tokens for a green completion Relative to Python within each model
Python 4,037–4,213 1.00×
TypeScript 6,135–6,255 1.48–1.52×
Go 5,583–6,837 1.38–1.62×
Rust 6,066–6,601 1.50–1.57×
Java 6,611–6,742 1.60–1.64×
Scala 5,298–8,348 1.31–1.98×
C++ 8,109–9,240 2.01–2.19×

On these successful traces, the most compact and most verbose cases differed by roughly two times. That compounds across generated files and follow-on prompts. It does not mean "twice the invoice": providers price input, cached input, and output differently, while local inference has another cost structure. It does mean language can change a major input to that invoice.

Why the footprint changes

This is not a contest between dynamic and static typing. The data does not support that simplification. TypeScript, for example, was in the middle of the observed range despite its type annotations. Go, with explicit error handling, was relatively compact in one configuration and less so in the other. Scala varied considerably. The practical unit of analysis is the language ecosystem, not syntax alone.

Several mechanisms interact:

  • Representation density. Imports, declarations, type annotations, error paths, templates, and resource-lifecycle code all consume output.
  • Library and build surface. A standard library can compress a task; an HTTP, JSON, or parsing stack can add setup, configuration, and constraints.
  • Toolchain feedback. Compiler diagnostics can require another large prompt and repair response; dynamic-language failures may emerge at runtime. Measure cost to a validated artifact, not first-draft brevity.
  • Model familiarity. Models learn ecosystems unevenly; recognized idioms can yield cleaner output than theoretically terser unfamiliar tooling.

This also explains why the middle of the ordering moved between the two model conditions. Language choice has an effect, but the size and ordering of that effect are model-, prompt-, toolchain-, and task-dependent. It would be a mistake to turn one benchmark into a permanent ranking of Python, Go, Rust, Java, Scala, TypeScript, or C++.

Measure cost to green, not code length

A useful internal metric is tokens to green: initial prompt and completion tokens plus every public-test diagnostic, repair prompt, and repair completion needed to produce an artifact that passes independent validation. Track it with the probability of reaching green under a fixed budget. A language that emits a short first draft but repeatedly fails compilation can cost more than a wordier language that works first time.

Keep this distinct from source bytes, completion tokens, wall-clock latency, and money. Source size is model-independent and useful for explaining code shape. Provider tokens measure model interaction but use vendor-specific tokenizers. Money requires the dated input/output/cache price schedule and, for self-hosted models, hardware and energy assumptions. Those measures answer different questions; collapsing them into one "cheap language" score hides the trade-offs an engineering organization must actually make.

Read the result as evidence, not a verdict

This research covers one composite task, a minimal-foundation dependency policy, greedy decoding, and few traces. A successful single run shows that a solution can work; it is not a Pass@1 estimate. The run history also contains failed and infrastructure-error attempts, so selected green runs are not an all-runs success rate.

Nor does it isolate a causal "syntax tax." Runtimes, libraries, compilers, and prompt appendices differ. The defensible claim is about a tested model × language ecosystem × task × protocol combination.

Stronger claims need multiple task instances, a preregistered seed schedule, fresh-session replication, reviewed references, two dependency policies, and all failures retained in token and money success curves.

How language cost should enter an architecture decision

Language token economics deserves a seat at the table, not the head of it. A team should first choose a language that fits the system it must build and the organization that must run it. Common decision factors include:

  • Engineer and reviewer fluency. Developers must inspect, debug, test, and safely change LLM-written code. Low token use is a false saving if changes queue for the only qualified reviewer.
  • Requirements and non-functional constraints. Latency, throughput, memory, real-time behavior, portability, and security can make a higher-token language the correct choice.
  • Runtime economics. A verbose language may produce a faster or cheaper service; small inference savings can be dwarfed by production cost.
  • Ecosystem, integration, and lifecycle. Existing services, formats, SDKs, observability, package provenance, security response, and support policies frequently dominate the decision.
  • Correctness and governance. Type systems, testing, static analysis, audit requirements, safety standards, and blast radius affect ownership cost.
  • Hiring and operational resilience. Talent, on-call coverage, documentation, and transferability are durable costs.

Measure the languages you already use. Add language to an AI engineering dashboard beside model, task type, pass rate, repairs, latency, source size, and unit cost. Segment by task, compare green artifacts rather than completion lengths, and retain failures rather than hiding them in an average.

The takeaway

Model selection remains important, but it is not the only structural lever on AI coding cost. In this benchmark, the same validated task required materially different token footprints across language ecosystems. Use that as a prompt to instrument your own workflow — not as a reason to abandon a language that fits your people, product, and operational constraints. The best language for an LLM-enabled team is the one that delivers the required system safely and sustainably, with token economics counted honestly among the trade-offs.