ai

Nim Sadeh 2025-05-08T15:10:54.114629Z

Has anyone else noticed that AI code generators love overusing atoms in Clojure? I wonder where that is coming from, is there a massive codebase somewhere overusing atoms that it's learning from? I would expect this pattern from a junior engineer who is used to writing in e.g., Python or Java and hasn't grasped functional or declarative programming style, but not from an AI which I expect to mostly regurgitate codebases it has ingested.

Samuel Ludwig 2025-05-08T15:18:50.277889Z

what prompt are you using? i'll try and find the link of the one i use the thing i run into most frequently/annoyingly is hallucinations of functions that either don't exist, or don't work in the way it claims to

Samuel Ludwig 2025-05-08T15:20:15.872669Z

(i use this, minus the re-frame stuff https://github.com/ovistoica/emacs/blob/main/prompts/clojure-expert.md)

👀 1
Nim Sadeh 2025-05-08T15:20:24.668919Z

I just ask it a simple question, like I have x function but it's bugging on this input, how do I fix. Or "set up a test for this function"

Nim Sadeh 2025-05-08T15:20:53.027999Z

That's a great resource, thanks! Do you feed it into ChatGPT or set it up in a code editor like Windsurf?

Samuel Ludwig 2025-05-08T15:22:22.201469Z

i dont use it super frequently (because often im looking for the things that its deciding to hallucinate), but i usually feed it into whatever model on Kagi Assistant, i haven't reached the hooked-into-editor point yet :^)

raspasov 2025-05-08T17:25:18.862719Z

I haven’t noticed that, but I don’t use them much.

raspasov 2025-05-08T17:27:40.361469Z

Is it using the atom to log/save some temporary data for debugging during REPL development? That can be a legitimate use, I use atoms to log/save stuff to observe what is happening.

Nim Sadeh 2025-05-08T17:43:39.074059Z

It mostly uses atoms like a procedural programmer uses variables, as a place to store and mutate state during a computation. Again just like a junior programmer who hasn't been trained on persistent data structure and functional-declarative style. That's the weird part for me

john 2025-05-08T18:51:10.632699Z

It's the obvious way to map some mutable algorithms over to clojure, right? I used to do that before I could recognize what mapped to functional idioms iirc

john 2025-05-08T18:53:36.645019Z

I do think you can prompt it towards a more functional mindset. Explicitly telling it to try to avoid using local atoms might help

john 2025-05-08T18:56:29.403679Z

That being said, even naively mapping to some local atoms based solution is still going to have safer concurrency semantics than a more idiomatic port

walterl 2025-05-08T21:31:11.079779Z

Can't say I've noticed an abundance of atoms with any of the models I've used (via Cursor), but @petrus's https://github.com/theronic/clojure-prompts may help

👀 1
2025-05-13T14:16:58.769849Z

I recently rewrote some python code in clj, using Cursor and noticed it was using atoms and had to several times suggest using either a reduce or a loop recur. Once suggested it did it correctly

Nim Sadeh 2025-05-13T14:49:08.848969Z

Yea +1 on guiding it to use reduce/loop, it's hard one-shotting it without a good system prompt though