logoalt Hacker News

Why Target Common Lisp for Code Generation?

142 pointsby oumua_don17yesterday at 8:40 AM124 commentsview on HN

Comments

fab13ntoday at 9:10 AM

My gut feeling is, this post is 180° wrong. LLMs are the exact opposite of "elite coders", they're perfect StackOverflow users:

* they memorize adapt and write back small-scale patterns very efficiently; * they know widespread libraries inside out, and can learn others in minutes, even if their doc sucks; * they often produce good results, because most of the time we write unoriginal code, which paraphrases something it already has dozens of versions of in their training corpus; * but they're bad at seeing meaningful, non-obvious, simplifying abstractions, we really have to spoon-feed those to them; * they _love_ verbosity, that's literally how they "think"; * they also love repetition: the other term for "repetition" is "patterns", and they're basically excellent pattern matchers.

So, Lisp is enjoyable for your typical LLM-complementary hacker, but not for LLMs. LLMs typically replace the kind of "non-elite" developers who hated Lisp, for remarkably similar reasons.

What I'd love would be an LLM trained to faithfully rephrase a "normal" program into Lisp-ish pseudo-code, that would make reviews faster, more reliable, more enjoyable. But hand-written code is going the way of hand-written machine code; let LLMs have what suits them best, and higher level tools for the more abstract jobs where we're still relevant, and that would be various forms of code reviews.

As for calling "elite" the kind of developer won't understand that development is a team sports, and that the proper tool is the one that fits the team, not their own peculiar quirks, I'm not going to address that, it isn't the keystone of his argument; but a lot could and should be said about that too.

show 1 reply
varountoday at 12:24 AM

I spent the last year writing substantial Common Lisp, including a FoundationDB client and distributed systems primitives layered on top of that, an observability and operability library for CL systems, and a large scale log, metrics and tracing platform that leverages these - in about 200K lines of code and tests. My take on this, apart from one of familiarity and personal preference/taste in choosing a programming language, in the age of LLMs are - 1. From a “functional requirements” perspective, any language will do. You can build substantial systems in something low level like C or higher level like Python or Common Lisp for example. 2. From a security perspective, if you are using LLM assisted code generation, whether you use C or Rust or Common Lisp does not really matter I think - current models are capable, and future models perhaps more so, in producing secure code.

My understanding is that LLM are deflationary, resulting in code being priced as a commodity (cost plus). If this bears out, then lower token costs and higher performance (esp in my case, where good performance results in lower infra costs to host the service) will start to matter more and more. Common Lisp code bases are famously dense (in the good sense), resulting in perhaps lower token costs when an LLM needs to review and make a change (smaller code bases also help humans / small teams). Common Lisp can achieve performance that’s close to that of an equivalent implementation in C or C++.

Taken together, they make for one case for using CL and other similar languages, although one that’s grounded largely in economics.

show 4 replies
willquacktoday at 3:45 PM

> You cannot successfully orchestrate an AI in a language you don't deeply understand.

This is the primary point and maybe even the later points may be, at least partially, an extension of it.

Coding agents reflect the developer using them, if the developer isn't proficient with the ecosystem they're developing in or problem they're solving, the output will still be bad. If the developer is lazy, the output will reflect that.

TurboHaskaltoday at 8:00 AM

Yeah no thanks. Common Lisp is the only language that still brings me joy in a post LLM world and I'd like to keep it that way.

kukkeliskuutoday at 12:58 PM

In many of my LLM projects, I have been using DSLs for all kinds of purposes. As many of these projects, data is kind of central, I use Django. So for these DSLs, hy (lisp combined with python) has been working quite well. I have not had trouble with Claude Code writing hy code.

abbefaria27today at 3:48 AM

I spent quite a while trying to learn Common Lisp and I really wanted to like it, but I’m not sure I’d recommend it. The first problem is finding good learning materials, as most are out of print. On the language side people complain about the parens, which turns out is no big deal. There’s a lot of other weird or needlessly tricky stuff though. The function names are convoluted (e.g. there’s map, but also mapc, mapcan, mapl, maplist). Image based development was interesting, but you might waste an hour debugging because your image diverged from the actual code. Building an actual executable is more complicated than you’d expect, and there’s a lot of magic with packages. There’s some elegance there if you squint, but other lisps are probably better.

show 3 replies
tigermelvilletoday at 4:22 AM

Wrote my first Lisp program in high school 1974; during a teacher's strike some of us geeks bussed it down to the University of Toronto computing centre. It was cafeteria system with a room full of keypunch machines. You typed up your program and got in line with your card deck. The line started with some silos of job cards. You could write fortran, lisp, pl/1, watbol, snobol, etc and run it on an IBM 360 mainframe.

You placed your deck on top of the card hopper when your turn came up. Most programs were 1/2 inch of cards so there were lots of jobs in a hopper that would take two feet of cards.

The line continued until a 1442 line printer at the end where your resulting printout came reeling out at alarming speeds. Operators handed you your printout and you returned to the keypunch room to review your results and make the necessary changes to your card deck.

The cool thing was we were obviously 15 years old and definitely not attending U of T. And our jobs were plainly not for a class because our card decks were 1 1/2 inches thick with long printouts of gameboard configurations.

But nobody ever batted an eye. We went every day for months.

Eventually I went to Uni during the era of the lisp machines. I worked for a professor who got me an office in the cpsc building. He paid me slave wages but the Lisp Machine lab was across from my office so they gave me a key to let people in who didn't have theirs. Bunch of Symbolics 36xx machines running chaosnet. A loud but life altering experience spending time in there. I spent enough time that I had a cot in my office.

That was mid 1980s, and I've carried on writing Lisp to this day. I still like to run that emulated Symbolics environment that's out there. To this day it's a very effective Lisp environment. The design of the REPL alone is blow-your-mind.

Am I elite? No, but my beard is grey. And on the subject of code generation, the last thing Symbolics did was port their code to the DEC Alpha, the first 64 bit chip. The port compiled their code into lisp macros that expanded to DEC Alpha instructions. The plan was to use different macros for different chips, which was done when the Power PC chip came along.

Then somebody at MIT wrote a little C backend that pretended to be a DEC alpha, and used macros that expanded into calls to the little C backend. That's what allows us to run a mid 1990s Symbolics 3600 image on any of today's 64 bit machines.

Athanase000today at 12:31 PM

I guess a weakness of the common benchmarks (artificial intelligence, gertlabs, and others) is that, from my understanding, they don't really cater to each language's specificity. If a language such as CL or Clojure boasts a superior REPL experience, that's entirely ignored by benchmarks, because they just look at the result of generic prompting. So maybe instead of writing countless blog posts on the superiority of such and such language, we should work on improving the benchmarking methodology. Then we would get more useful results.

CuriouslyCtoday at 11:12 AM

I love lisp, but I don't think the syntax is ideal for LLMs because they generate left to right, and lisp is deeply nested by design. Functional languages that have pipe operators and other features to keep code reading left to right, and strong type systems seem like the sweet spot.

show 1 reply
shricyesterday at 11:32 PM

I’m fascinated that some people in our field choose to self describe themselves as “elite”.

Are there any programming/computer science greats that self aggrandize like this? Is it a cultural thing somewhere that I’m not aware of?

show 17 replies
PrimalPowertoday at 12:01 AM

I don't know if anything has changed, but last time I tried codegen for Common Lisp, the LLM would routinely mix up LISP dialects and language specific features.

Less so with Clojure.

show 2 replies
xdavidliutoday at 2:22 AM

> You are not writing dead text; you are conversing with a living system.

There it is again.

show 1 reply
mintflowtoday at 6:42 AM

I only touch some emacs lisp and never do Common Lisp But seems years of coding experience make me think those tenets in the article reasonable There are indeed elite programmers as I see in my career it’s rare also we do not need to be sad Maybe it’s time to learn some Common Lisp given it’s a good day for exploration and prototyping

kodomantoday at 12:30 AM

I have been using cl for a project recently, as it had many features I wanted and actually made sense to use despite not being familiar with it (though used elisp and a tiny bit of scheme). I found it mixed some things where fantastic some things remain pain points, SBCL is a fantastic project and compiler and once you get used to the debugging it's a very nice experience with slime. It is true to say that it's flexibility is fantastic and CLOS object system once you get used to it is very nice. On AI assisted coding I found it mixed and though Claude now seems quite good at it, local models can be quite poor and lots of things are a lot less well documented and the fact that there is less code out there. One thing to look out for with local models (and probably even the frontier models but with there larger size negates the issue entirely from my usage) is that '(' or ')' might be part of a token such that '))' is a discrete token and '(*' might be as well, all that is to say that when it writes code terminating and start blocks can be an issue so your parens will be off, this was when using omnicoder 9B and that was the main issue. not sure how more recent local models function as switched to claude for part of it and tended to prefer to take my time and write the code myself.

tehologisttoday at 3:14 AM

I was under the impression LISP is nice to write and work with but difficult to read. How well can you understand LISP written by a LLM?

show 1 reply
rodrigosettitoday at 2:03 AM

Google is making the opposite argument to support Go as the ideal language for vibe coding (https://news.ycombinator.com/item?id=49261133) - i.e., not expressive by design, lowest-denominator, etc.

show 1 reply
mark_l_watsontoday at 3:22 AM

In the mid 1980s I wrote a commercial neural network product SAIC Ansim and I usually got things working in Common Lisp first, then manually translated to C++. Now we can write in CL and use coding agents to translate to other languages... progress!!

asgrtoday at 1:26 PM

“<———— elite hacker” - funcall-blogger

natmakatoday at 11:54 AM

Isn't it also in order to reduce dangerous side-effects?

tehologisttoday at 3:16 AM

As an aside, I wrote a dialect of forth and LLM was pretty good about constraining itself to a subset and create fairly usable code. I was having it implement cordic functions to implement sin/cos.

sillysaurusxtoday at 12:32 AM

One annoying part of SBCL is that it does something up front with its memory such that if you run it with an 8GB heap, running shell commands takes a noticeably long time even for "echo hi". It’s something to do with the way it forks. Shell commands are also serialized, meaning multiple threads running curl won’t help you more than a single thread running curl. This is in contrast to almost every other programming language, which lets you get more performant network fetches by running the requests in multiple threads. The only alternative to curl is to use a library that simulates curl or write your own, which is fraught with errors: if any piece of the connection times out, it has to gracefully terminate, which is harder than it sounds when you’re interfacing with OpenSSL directly.

I think that covers my list of grievances though, and it’s a pretty short list. Other than those, CL has been good to me.

bryanrasmussentoday at 7:11 AM

I find only the first reason convincing, and this would obviously be the case for any programmer, just as you choose to implement in a language best for the task at hand that you know well, you should choose to vibe code in the same way.

Of the other reasons - when he says >Most modern languages force you to describe exactly how a machine should shuffle bits around.

he must mean something very differently from what I mean if I were to say shuffle bits around, because this is normally what I think most modern languages don't force you to do.

the elite thing seems not to mean much.

>Homoiconicity and the AST

maybe, I would expect predicting well known syntax would be easier for an LLM, but he says it's not. So... maybe?

>Macros as Context Compression

Wait, is the LLM generating macros? But LLMs have well known propensity to verbosity. That is to say in these other languages experts in those languages find the code the LLM generates overly verbose. But not in Lisp, or is it that he writes a macro and tells the LLM use that, but I mean other language experts can write a function and say use that instead of your more verbose methods?

>Superior Error Handling

shouldn't we have the LLM generate Erlang?

I mean I get the reasons to go off on how your language is superior and great and do the arguing about all sorts of features and I am all for Lisp or Scheme as maybe the greatest, but the language snobbery in support of LLM target choice just seems weird. Like arguing about why the cream filling in Twinkies is superior to that of Choko-Diles.

Maybe I am just not keeping up on the latest frontiers of language snobbery anymore.

show 1 reply
nineteen999today at 10:17 AM

> 3. Designed for the Elite Let’s be honest: Lisp is a language designed by and for elite hackers

... it took them up to item #3 this time? Usually i see this quoted as item #1

dismalaftoday at 12:49 AM

Was going to write something about the article but then poked around the blog and it led to Github including this gem: https://github.com/jrm-code-project/llambda which is much more interesting.

I do agree with a lot of the article though, Lisp plays nicely with LLMs. Definitely had better luck with Lisp and LLMs than C++ or Rust.

Also, kind of random, but here's an interesting tool to use CL with LLMs: https://www.lambda-symbolics.com/autolith

stackghosttoday at 12:27 AM

>I do not operate the LLM in a sterile text editor. I operate it from within a Lisp REPL

I'd be very interested in reading more about this.

meeritatoday at 12:54 PM

[flagged]

samso26yesterday at 11:53 PM

[flagged]

ohaodhatoday at 12:22 AM

[dead]

charcircuittoday at 7:23 AM

[dead]

rhet0ricatoday at 12:39 AM

[flagged]

show 2 replies
a2ff6eeb0today at 12:02 AM

In short: sunk cost fallacy.

show 1 reply
sroericktoday at 5:32 AM

How do you teach LLMs to close parens properly??

show 1 reply