HN.zip

I checked Clojure's core with Lean and found unreported bugs

79 points by - 24 comments
[3 hidden]5 mins ago
While the effort is interesting, I found two issues in the list.

First, (.indexOf (seq (byte-array [1 2 3])) 2) fails because byte arrays store bytes and the argument 2 to `.indexOf` is a Long value. Simple type checking (via eyeballing) could have flagged the incorrect usage. I think such exercises can be more helpful if we can reduce the noise.

Second, (get "abc" 1.9) fails because `get` coerces the given key to integer in the context of string objects, which makes sense; specifically in the context of weakly typed language. That said, I believe that detailed documentation of the behavior of `get` can help clients just as well as returning `nil` or not-found value. However, we are still left with questions such as "who and where do we draw the line about the dynamism of the language?" and "what is the agreed upon semantics that we are checking against?"

[3 hidden]5 mins ago
Having long admired clojure and Rich, I wonder what Rich makes of AI / agentic coding. I can imagine him having something really interesting and surprising to say, or being very anti-AI in an entertaining and persuasive way that ultimately feels destined to be a losing argument.
[3 hidden]5 mins ago
He has a very elaborate anti-LLM stance: https://www.linkedin.com/pulse/ai-tool-rich-hickey-kjl8e

Sadly, posted on LinkedIn, but in a nutshell, he claims that LLMs are not a tool, they are intrinsic automation.

And by using them, you are kinda giving up.

[3 hidden]5 mins ago
I was sad when I read this. I thought Clojure + LLMs was like a match made in heaven for some reason
[3 hidden]5 mins ago
It's one man's opinion, albeit the creator of the language. People will disagree and that shouldn't stop you from doing what works best for you.

Just the other day, someone told me "AI tools can write better code than you, right?", that gave me a chuckle. Yet that attitude is pervasive, I worry it encourages people to let the tool do all of the work. At that point I find myself agreeing with Rich: is it even a tool anymore?

[3 hidden]5 mins ago
Interesting, why? Whenever I have used LLMs with Lisps, they always get tripped up balancing parentheses due to the tokenization.
[3 hidden]5 mins ago
The REPL loop is really fast for prototyping. The parens balancing thing hasn't been an issue for like 18 months.
[3 hidden]5 mins ago
Have written millions of lines of lisp with LLMs (mostly clojure). I have never had this issue in any meaningful quantity comparable to forgetting ; or } (which happens, but is very rare and immediately fixed)
[3 hidden]5 mins ago
abstraction with macros, minimal syntax (((except these), and giving the LLM direct access to a REPL, to test as stuff is written.

I have used Lisps with LLMs a bit. I toyed around with an indented Lisp I developed with LLMs, to get rid of all the parenthesis, maybe make the LLM more capable of writing it since it looked somewhat closer to Python. I still play around with it, its nice to look at.

[3 hidden]5 mins ago
he has expressed anti-AI opinions but it's apparent he's not really used them extensively
[3 hidden]5 mins ago
There was this post https://news.ycombinator.com/item?id=46415945 almost a year ago regarding his opinion on AI.
[3 hidden]5 mins ago
On the practical side, Clojure sits on top of JVM which is humongous and likely unverifiable. On the theory side, very exciting!
[3 hidden]5 mins ago
Looks like Rich needs to get back to his hammock
[3 hidden]5 mins ago
Not sure what you understand "hammock-driven development" to be for, but it is not a tool meant for producing bug-free implementations.
[3 hidden]5 mins ago
Somebody woke up on the wrong side of the hammock
[3 hidden]5 mins ago
The underside? Ouch
[3 hidden]5 mins ago
I'm not sure the lisp community could consider these bugs.

Lisp/clojure/scheme etc is inherently untyped. These libs don't guarantee anything near to the level that a formal verification would suggest.

If this were the haskell standard lib however, that would be news.

[3 hidden]5 mins ago
The article I read described clear correctness bugs unrelated to types.
[3 hidden]5 mins ago
Some of these issues are actually quite bad and don't have anything to do with types at all
[3 hidden]5 mins ago
Even the types in Haskell are far too weak to be included in what we mean by "formal verification" (not to say they're not useful for some things, just that this is not the level of specification that formal verification is typically about). If we rank the strength of properties we can express with types in Clojure as 0 and in Haskell as 3 (or, say, 7 with refinement types), then the strength of types required for formal verification (e.g. in a language like Idris) would be 100.
[3 hidden]5 mins ago
Indeed. I’ve viewed Haskell not as a high bar to clear. It’s rather low. And most languages don’t even clear it.

Things trickle down to Haskell from higher up but it takes a long time to incorporate them. Dependent Haskell has been in the making for like… 9 years? Maybe more? And it’s still being debated whether Haskell should even adopt it.

The type theory needed for formal proofs is much more advanced at this point. Idris, Agda, Lean, Roq… this is where you need to look to see the 100’s.

[3 hidden]5 mins ago
Lisp is not untyped. It is dynamically typed.
[3 hidden]5 mins ago
Types have nothing to do with it. For example, the first bug in the article is about an infinite loop in a core data structure:

“[…] reduce it, the call never returns once the vector has 65505 or more elements.”

> These libs don't guarantee anything near to the level that a formal verification would suggest.

This is just plain wrong. A lisp library can absolutely make performance and correctness guarantees, and formal methods can refute or verify those guarantees. A type system is just a special kind of formal method that can rule out certain classes of bugs.

[3 hidden]5 mins ago
I'm glad I checked your other comments! Beautiful counter bait