Unofficial Hacker News companion — get notified on comment replies, and more.

Why stop at Emacs? Native apps you or an AI reprogram in Clojure while they run (opens external site)

153 points by RiccardoSottini 4 days ago | github.com | 110 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (18)

  1. What is the benefit of using clojure now? Used to be a big Lisp head before AI, but with AI I feel like using widely-used statically-typed, strongly-typed languages is better over Lisp, for the training set and validation benefits.
    Replies (6)
    1. Lisp/Clojure is token efficient for AI-assisted coding: https://martinalderson.com/posts/which-programming-languages.... I also find Clojure's open maps and data-first style better suited to prototyping than rigid types. You or the AI can reshape the data while the app is running, without rewriting type definitions. When the design settles, you can add spec/Malli and validation.
    2. It looks like they are just borrowing clojure syntax (I like), and perhaps the culture of supporting hot code reload (I also like), but I share the same reservations.
      Replies (1)
      1. Both are valid points and some of the reasons why + the fact that it is super "token friendly" allowing to express logic and have functionalities expressed in just a couple of lines
        Replies (1)
        1. obv I could clone and ask an AI but since you're here, https://github.com/RiccardoSottini/AffrescoUI/blob/master/ex... is a limited syntax definition for the built-in markdown parser?

          I went down a similar path using smalltalk. Then as I started to play whack-a-mole with UI edge cases (live markdown editor), the loop became tedious because I had to use the app to find the interaction bugs (what to do about link rendering when the cursor enters, leaves, and when exactly to prettify and unprettify), while suspecting that this has been solved 100x over in javascript land. Sure enough, when I moved to bb, I had to pull in a lot of libs, which is a lot of pregenerated tokens, but those were battle tested tokens.

          I guess it has to be done though, as long as you bring a new stack.

    3. Listened to this a couple days ago: https://m.youtube.com/watch?v=tzzg8CVkl2A

      Besides immutability and iterating with the repl, another point made was apparently more efficient context window usage due to fewer lines of Clojure code compared to alternatives.

      Replies (2)
      1. Yes! That's the reason why I chose it - due to iterations with repl and extremely efficient context window usage / token expenditure. Effectively, for the use case scenario of my project, Clojure can express logic and functionalities that are shown on screen with just a couple of lines of code, removing all the boilerplate/overhead code.
      2. Cool talk. I've expected Lisps to be the winner for these reasons.

        Here is a similar talk from Anurag Mendhekar at the European Lisp Symposium a year ago:

        Is Lisp Still Relevant in the New Age of AI? [video]

        https://news.ycombinator.com/item?id=50671492

    4. Live editing running applications.

      You could be using your app to solve some problem, and just modify it instantly with a prompt to just-in-time add a new feature. No need to shift between “using the app” mode and “programming the app” mode.

      Replies (2)
      1. Yes, those are the main points. I believe that it is also fundamental to also maintain versioning and data migrations, so, each time you try edit/add a new feature, you can switch between the different versions/rollback - and most importantly you do not compromise data - as there's a fine line between full software malleability that has no control of any sort (and issues can arise) - and a framework that allows such an experience but has some sort of "guardrails".
      2. I mean that's just any language with a REPL?
        Replies (2)
        1. Image based languages are fundamentally different from others and the similarities end at "has a repl"
          Replies (1)
          1. You just need a way to preserve state between module reloads. Hardly revolutionary.
        2. Every stage in Read-Eval-Print-Loop differs. So it's not "just any language with a REPL", no. Lispers call Lisp REPL "a true REPL", not for emotional reasons, for quite practical ones.
    5. > statically-typed, strongly-typed languages is better over Lisp

      Nope, in practice, that point turned out to be not exactly accurate. Giving an agent access to the "true Lisp REPL" makes it stop guessing and start empirically analyzing the current state of things. It reaches decisions faster, costing far fewer tokens. You just need to build a proper, "Lisp-aware" harness.

    6. The same features that help humans also help agents. For example, immutability as the default helps minimize the scope an LLM needs to track in order to make a change correctly. Clojure being concise and expressive also helps reduce the amount of tokens the LLM needs to use which directly shrinks the context. The language is also data focused, so the LLM can inspect any data or state trivially. And nREPL driven workflow provides the agent with a fast feedback loop where it can try things and iterate step by step.
      Replies (1)
      1. Yes, you got it right. As you said, where you find benefits for humans, you find similar benefits for the LLMs too - e.g. As Clojure has got such a compact syntax, it's both easy to comprehend by humans and lower token consumption. Have you got any other ideas on how I can leverage best such benefits?
        Replies (1)
        1. I've ended up building some tooling for the harness to use to work with Jolt which help the LLM get oriented and use the language effectively.

          I have a language server and agent toolset https://github.com/jlt-commons/jolt-lsp

          Then there's an MCP for using nREPL https://github.com/jlt-commons/jolt-nrepl-mcp

          running metrics helps catch problem like tight coupling, high cyclomatic complexity, code duplication, and so on https://github.com/jlt-commons/jolt-metrics

          And I've tied it all together with a set of skills for the agent to use. https://github.com/jlt-commons/jolt-skills