{"slug": "ask-hn-how-to-avoid-llms-struggling-with-lisp-parens", "title": "Ask HN: How to avoid LLMs struggling with Lisp parens?", "summary": "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.", "body_md": "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.\n\nThis is frustrating for two reasons:\n\nFirstly, 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.\n\nSecondly, balancing parentheses is *trivial* for traditional, non-LLM algorithms; so it feels like an entirely avoidable problem (without resorting to larger, more-expensive models).\n\nIs 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?\n\nComments URL: [https://news.ycombinator.com/item?id=48657691](https://news.ycombinator.com/item?id=48657691)\n\nPoints: 2\n\n# Comments: 0", "url": "https://wpnews.pro/news/ask-hn-how-to-avoid-llms-struggling-with-lisp-parens", "canonical_source": "https://news.ycombinator.com/item?id=48657691", "published_at": "2026-06-24 10:22:37+00:00", "updated_at": "2026-06-24 10:44:26.725357+00:00", "lang": "en", "topics": ["large-language-models", "ai-tools", "developer-tools"], "entities": ["Claude", "DeepSeekV4", "Emacs", "Racket", "Lisp"], "alternates": {"html": "https://wpnews.pro/news/ask-hn-how-to-avoid-llms-struggling-with-lisp-parens", "markdown": "https://wpnews.pro/news/ask-hn-how-to-avoid-llms-struggling-with-lisp-parens.md", "text": "https://wpnews.pro/news/ask-hn-how-to-avoid-llms-struggling-with-lisp-parens.txt", "jsonld": "https://wpnews.pro/news/ask-hn-how-to-avoid-llms-struggling-with-lisp-parens.jsonld"}}