cd /news/large-language-models/ask-hn-how-to-avoid-llms-struggling-… · home topics large-language-models article
[ARTICLE · art-37592] src=news.ycombinator.com ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Ask HN: How to avoid LLMs struggling with Lisp parens?

A developer reports that large language models consistently struggle with balancing parentheses in Lisp dialects like Racket and Emacs Lisp, leading to cascading syntax errors. The user seeks workflows or tooling that can help LLMs handle Lisp code effectively, noting that traditional algorithms can trivially solve parenthesis balancing.

read1 min views1 publishedJun 24, 2026

LLMs seem to love certain languages (Python, Bash, etc.), but they all seem to struggle with Lisp (e.g. Racket or Emacs Lisp). I've tried various iterations of Claude, as well as cheaper models like DeepSeekV4, etc. and the pattern is the same: they'll make a few successful edits, but eventually they'll get some parentheses slightly wrong, then spiral into madness as they attempt to fix the syntax errors by counting and matching-up parentheses "manually" in a never-ending loop.

This is frustrating for two reasons:

Firstly, LLMs are famously bad at counting characters (e.g. the number of "r"s in "strawberry"), so it's no wonder this approach of generating and counting characters doesn't work very well.

Secondly, balancing parentheses is trivial for traditional, non-LLM algorithms; so it feels like an entirely avoidable problem (without resorting to larger, more-expensive models).

Is anyone using LLMs successfully on Lispy projects? If so, what workflows, tooling, etc. have you found to work well? I've tried guiding them to use Emacs check-parens rather than counting "manually"; but maybe inferring from indentation might work better? Perhaps tree-based generation/tools would avoid introducing such problems in the first place?

Comments URL: [https://news.ycombinator.com/item?id=48657691](https://news.ycombinator.com/item?id=48657691)

Points: 2

── more in #large-language-models 4 stories · sorted by recency
── more on @claude 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/ask-hn-how-to-avoid-…] indexed:0 read:1min 2026-06-24 ·