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: Concrete token counts (140 vs 12) from a first-person experiment, hitting all three HKR axes. Deduction: the second half drifts into personal narrative without systematically cataloging all anti-patterns—reads more like work notes than a complete guide. 72, just clearing the f...

Read the original ↗Export Markdown