Skip to content
Hacker News front page

LLMs default to legacy code patterns, inflating output token costs 3–5×

What I'm Finding About LLM Code Style and Token Costs

Jim Montgomery finds that LLMs like Claude default to legacy Node.js patterns—manual URL parsing, per-field form state, hand-rolled async coordination—instead of using Web APIs already built into browsers and modern runtimes like Deno. The token difference is stark: ~140 tokens for manual query parsing vs. 12 for URLSearchParams; ~200 tokens for a 3-field React form vs. 14 for FormData. Since output tokens cost 3–5× more than input tokens in API pricing, these defaults waste money and introduce bugs. The fix is telling the model which runtime APIs are available in your prompt.

Why it matters: Jim Montgomery compared two ways Claude writes Node.js code: parsing query parameters by hand costs about 140 tokens, while URLSearchParams needs only 12.

Read the original ↗Export Markdown