编写 Lisp 具有抗 AI 能力,我很伤心。
Writing Lisp is AI resistant and I'm sad

原始链接: https://blog.djhaskin.com/blog/writing-lisp-is-ai-resistant-and-im-sad/

一位DevOps工程师,同时也是一位热衷于Lisp编程的开发者,发现了一个令人沮丧的讽刺:AI模型明显*更喜欢*使用Python和Go等语言进行编写,而主动避免使用Lisp。在使用OpenRouter和Goose等工具进行代理AI任务(例如RSS feed转换)时,这位工程师发现AI在处理Lisp的REPL驱动开发时遇到了极大的困难。 尝试使用自定义工具(`tmux-repl-mcp`)来简化REPL交互有所帮助,但成本(轻松达到10-20美元,仅取得微小进展)以及“信号与噪声比”仍然远不如Python。AI可以毫不费力地生成完整的Python代码和测试,而Lisp则需要持续的手动干预和调试。 这次经历凸显了AI如何利用现有的训练数据,偏爱那些具有高“互联网数据量”的语言。这位工程师将其比作一条被铁路便利性所取代的历史上的“木板路”——Lisp虽然令人愉快,但在AI辅助开发方面效率不如更流行的语言。这引发了关于Lisp的未来以及为了在AI时代蓬勃发展而需要进行的潜在调整的问题。

## AI 与 Lisp:格局变化 最近 Hacker News 上的一讨论探讨了 Lisp 是否正在变得“AI 抵抗性”——作者对此表示遗憾。虽然最初认为由于其独特的结构而具有抵抗性,但许多评论员报告称 Claude 和 GPT 成功地用于 Clojure 和 Common Lisp 编码。 核心问题并非 AI *是否* 能编写 Lisp,而是 *如何* 编写。许多人发现 AI 难以处理 Lisp 中常见的 REPL 驱动开发,以及括号匹配。然而,向 AI 提供完整的文件和清晰的指令可以获得更好的结果。 一个关键的结论是,AI 的性能与训练数据可用性相关。流行的语言(如 Python)受益于庞大的数据集,而不太常见的语言(如 Lisp)可能落后。有人认为 AI 的优势在于压缩和信息检索,使其非常适合具有大量在线示例的语言。另一些人认为 AI 的推理能力有限,而 Lisp 的固有复杂性构成挑战。 最终,这场讨论凸显了一种潜在的转变:AI 可能会偏爱具有大型代码库和既定工作流程的语言,这可能会在未来影响语言多样性。
相关文章

原文

In an insulting, ironic blow to the neats, the scruffies created an AI that much prefers to write anything but Lisp.

I use agentic AI a lot at work to do my job as a DevOps engineer. I use OpenRouter with the Goose CLI tool, and I've gotten a pretty good configuration file going with it.

I have lately started writing a tool that converts between different RSS reader formats. I started writing it in Lisp, of course. It's my favorite language.

I had a problem though. I had to teach the AI how to use the REPL. Initially, I had it run commands to interact with the REPL via tmux, e.g. tmux capture-pane -t 0.0 -p | tail -n 1. It worked okay, but I noticed that REPL development was very hard for the AI. Claude really spun its wheels. Lesser AIs would be very much worse. I'd blow $10-$20 in a handful of minutes with not much to show for it but sort of OK lisp code that I ended up rewriting. I tried doing it with cheaper AIs like DeepSeek and Qwen, which I found did OK at work for some tasks, but it wasn't working.

I figured maybe if I made REPL development smoother, the AI would do a better job. I wanted to give goose unlimited rights to the REPL while still guarding general command rights, too. So, I created a tool called tmux-repl-mcp that would make interacting with the REPL more straightforward. Instead of consuming a ton of tokens, executing a bunch of sleep commands, and parsing tmux output, the could just run execute_command in the repl and get its output.

I wrote this tool in Python since a lot of my AI tooling in my goose configuration file was built around uvx already. I liked that I just had to install uvx and all of a sudden goose could use all these tools. I already had all this stuff built up in my configuration file, so I figured it would be easier for folks to use if it were distributed in the same way. Besides, the official guide to write an MCP server were in non-lisp languages anyway.

The difference in writing Python and Lisp with AI was of course dramatic, downright wild. I got it to write all of the code and all the tests for the code. I had to debug it semi-manually, but I was still able to bang together this more-than-nothing tool in like a day or two, and with cheap models at that. Worst of all, the experience for me was the same in many ways: I wrote code by being a poor man's product owner to the AI for both, only the AI would perform well with the Python. I felt none of the happiness I usually feel just writing Lisp.

Going back to my actual project was painful. I ended up writing one of the files (src/newsboat.lisp) by hand. I was in the middle of debugging it when I realized how much harder it was to write with AI in Lisp. I had to switch back to Claude, which at least makes some progress relative to the others. The tmux-repl-mcp tool helped, but I still blew through $10 in like 30 minutes. The signal-to-noise ratio, or in other words, the wheel-spinning-to-progress ratio in the AI session was night and day compared to Python. And in AI, you pay for the noise and the signal together.

Now I'm thinking of rewriting it in Go. With AI, code is cheap, but only if you use a language for which AI has a lot of training data.

Another frustration has been tooling. Lisp has a lot of tools to choose from. I like using OCICL instead of QuickLisp, for example, but I had to tell the AI to not use quicklisp every single session. It was like built into the AI to use it. This also helped me realize that AI generates code sort of on a path of least resistance.

There are reasons other than a lack of training data that makes lisp particularly AI resistant. The high-latency request-reponse way we interact with AI APIs does not work well with REPLs. REPL development makes programming easier and better by reducing that latency for humans, but there's already high latency anyways in these APIs. The downside of not using REPLs is that you have to have higher accuracy when writing code and you can only test big batches of code at once, but AI can write hundreds of lines in one go so that it just makes sense for the AI to use a language that doesn't use the REPL.

It is orders of magnitude easier and cheaper to write in high-internet-volume languages like Go and Python than it is to write in Lisp. The advent of AI has converted language popularity into real dollars-and-cents-per-million-tokens cost savings. What's more, building in one language or the other makes no difference to how I experience the language; either way, in the ideal case, I'm a rather opinionated micro-managy product owner. That is really sad.

It reminds me of a tale that was told in my hometown about Plank Road in Naperville, IL. The nineteenth century roads were always muddy, so a bunch of investors created a road that was planked, or made of wood. The makers of the road would charge money for using the road. Later, the railroad offered to build a railroad through Naperville, but they declined, saying they were making plenty of money on the plank road, so the railroad was built in another city. Everyone stopped using the plank road in favor of rail, and it eventually survived only in name with no one using it in its original form.

I know money is not an issue here, at least for me. However, I can't help but make the comparison in my head. The Plank Road must have been way nicer to traverse than the muddy roads, evoking joy in the travelers when comparing it with travelling in the mud, just like Lisp makes me feel versus writing in something else. However, when the railroad came along, all the farmers had to do was load it into the cars. With ease like that, why use the silly road at all?

It's just another example of Worse is Better. However, Lisp has survived this worse-is-better internet era for decades. I wonder what we'll learn as it survives the AI era as well. I like the neats camp. It's more fun. I wonder what adaptations will be necessary to make AIs work better on Lisp.

联系我们 contact @ memedata.com