Skip to content
#small language model Dataset Open access

Token cost by programming language: the same programs in 10 languages on Claude, Gemini and GPT

Oct 2026 · Zenodo (CERN European Organization for Nuclear Research)
Software Engineering Research

Abstract

Two small programs (an inventory class and Dijkstra's shortest path) written in Python, Ruby, JavaScript, TypeScript, PHP, Rust, Java, C++, Go and C, with input tokens counted on Claude Opus/Sonnet 5.5, Claude Haiku 4.5, Gemini 3.x and GPT (o200k_base). Headline: both programs together cost 809 GPT tokens in Python and 1,536 in C (+90%). Python and Ruby were the cheapest on every tokenizer; Go and C the most expensive. Claude 5.5 needed 43% to 59% more tokens than GPT for the same code. Source page, chart and method: https://tokensave.app/data/token-cost-by-programming-language Related: token cost by data format (https://tokensave.app/data/token-cost-by-format) Measured: 2026-10-18 License: CC BY 4.0 Key findings Python and Ruby are the cheapest: 809 and 819 GPT tokens. JavaScript needs +20%, Java +50%, Go +68% and C +90%. The ranking holds on every tokenizer tested. Claude 5.5 costs 43% to 59% more than GPT for the same code (largest gap: Java). Gemini needs 12% to 25% more than GPT. Types add tokens: TypeScript needs 11% more GPT tokens than the same JavaScript. File size is a rough guide only: Java has the most characters, but Go and C need more tokens. Files token-cost-by-programming-language.csv: one row per language and program (inventory, dijkstra and total) with language, program, characters, lines, claude55_tokens, claude45_tokens, gemini_tokens, gpt_tokens token-cost-by-programming-language.json: the same data plus all 20 source files, so every count can be reproduced Data (both programs together) Language Characters Claude Opus/Sonnet 5.5 Claude Haiku 4.5 Gemini 3.x GPT (o200k) GPT vs Python Python 2,887 1,176 970 963 809 ±0% Ruby 2,478 1,181 961 944 819 +1% JavaScript 3,195 1,442 1,199 1,184 967 +20% TypeScript 3,610 1,590 1,311 1,288 1,070 +32% PHP 3,697 1,609 1,311 1,262 1,128 +39% Rust 4,081 1,815 1,452 1,411 1,189 +47% Java 5,101 1,934 1,551 1,511 1,217 +50% C++ 4,793 1,933 1,626 1,617 1,343 +66% Go 4,292 2,143 1,749 1,701 1,359 +68% C 4,843 2,219 1,859 1,820 1,536 +90% Method Each program written idiomatically in each language with no comments. Every version was compiled or run and printed exactly the same output as the Python version. Claude: each file sent through Claude Code (claude -p) with a fixed one-line system prompt; input tokens minus the same run with a one-character message. Opus 5.5 and Sonnet 5.5 gave identical counts; a re-run gave identical counts. Gemini: Google AI Studio prompt token counter on Gemini 3.8 Flash, minus its one start token. GPT: tiktoken with o200k_base. Limitations Two small programs. Comments, long names or boilerplate in real projects can shift the numbers; the ranking is more stable than the exact percentages. Coding style changes the count within a language. Input tokens only; not a measure of how well each model writes each language. Citation TokenSave (2026). Token cost by programming language: the same programs in 10 languages on Claude, Gemini and GPT [Data set]. https://tokensave.app/data/token-cost-by-programming-language

View source

Similar papers

#small language model Dataset Open access Oct 2026

Socratic guiding questions in synthetic arithmetic data: matched LoRA runs (revision v2)

Supporting data, adapters, predictions and code for the article *Low-Cost LoRA Fine-Tuning of Small Language Models for Multi-Step Arithmetic Reasoning* by Jake O'Grady, Asena Isik Gürhan, Chee Fong Ting and Effirul Ramlan (University of Galway). We generated 20,000 GSM8K-derived arithmetic problems with step-by-step s...

O'Grady, Jake, Gürhan, Asena Isik, Chee, Fong Ting et al. · 465 citations
#computer vision Open access Jun 2016

Software Development in Startup Companies: The Greenfield Startup Model

The results are packaged in the Greenfield Startup Model (GSM), which explains the priority of startups to release the product as quickly as possible, and the need to shorten time-to-market, by speeding up the development through low-precision engineering activities.

Carmine Giardino, Nicolò Paternoster, M. Unterkalmsteiner et al. · 178 citations · ⚡14
#computer vision Open access Oct 2016

Software Startups - A Research Agenda

Software startup companies develop innovative, software-intensive products within limited timeframes and with few resources, searching for sustainable and scalable business models.

M. Unterkalmsteiner, P. Abrahamsson, Xiaofeng Wang et al. · 157 citations · ⚡17
#machine learning Review Open access Oct 2016

“Failures” to be celebrated: an analysis of major pivots of software startups

This study conducts a case survey study based on the secondary data of the major pivots happened in 49 software startups, and demonstrates that customer need pivot is the most common among all pivot types.

Sohaib Shahid Bajwa, Xiaofeng Wang, Anh Nguyen-Duc et al. · 127 citations · ⚡15
#computer vision Review Open access May 2015

A survey study on major technical barriers affecting the decision to adopt cloud services

The comparison of adopter and non-adopter sample reveals three potential adoption inhibitor, security, data privacy, and portability, which underlines the importance of the technical and security perspectives for research investigating the adoption of technology.

Nattakarn Phaphoom, Xiaofeng Wang, S. Samuel et al. · 111 citations · ⚡8
#computer vision Open access Feb 2018

Lean Internal Startups for Software Product Innovation in Large Companies: Enablers and Inhibitors

This study investigates how Lean internal startup facilitates software product innovation in large companies and identifies its enablers and inhibitors, and shows the potential of the method-in-action framework to investigate the Lean startup approach in non-startup context.

Henry Edison, Nina M. Smørsgård, Xiaofeng Wang et al. · 78 citations · ⚡6

Related blog posts

MIT News · Artificial Intelligence Oct 23, 2026

Q&A: How AI came to model the “messy” human mind

Assistant Professor Benjamin Lindquist studies how engineers deliberately injected randomness into early AI, giving rise to deep-learning models that sometimes hallucinate.

Microsoft Research Blog Oct 22, 2026

Flint-interactive: A language for creating interactive data visualizations

Flint-interactive gives AI agents a language for creating interactive visualizations. Click a chart, filter data, highlight related content, and explore beyond the view the author originally chose. The post Flint-interactive: A language for creating interactive data visualizations appeared first on Microsoft Research.

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.