beginners

Noah 2025-07-19T15:39:25.592619Z

Just trying to get into Clojure and I am confused as to if I should use Leiningen or deps.edn (Clojure CLI-tools?). My goal is to use IntelliJ and Cursive, I am not sure how that plays in

p-himik 2025-07-19T15:42:00.651629Z

I'd suggest going with deps.edn. It cannot do every single thing that Leiningen can, but it can do everything among things that everybody need, and a bit more. And in general do so in a simpler and more sensible way than Leiningen. For things that can't be done with deps.edn by itself, there are other tools that you can neatly compose with each other.

👍 1
2025-07-19T16:23:14.049039Z

deps.edn may be "simple", but Leiningen is "easy". (We around here are groupies of R. Hickey's inspirational "Simple, made Easy" talk and the associated distinguishing definitions of simple and easy.) "Simple" should pay dividends; my long-term hopes are on deps.edn for liberating us from jar repositories and associated middlemen like Maven; but in the short run (and for the last 10 years) if what you want is what's provided by "lein repl", "lein run", "lein test", "lein classpath" then Leiningen is a time-saver.

Mario G 2025-07-19T16:58:54.818319Z

I would not overthink this. If undecided toss a coin and pick one of them. On the long run (if you stick around) you'll probably get familiar with both. But it's really good to know what both are and why they exists, and then you'll make your call. deps.edn is the official solution delivered by the same folks that maintain the language. It's very basic and minimal but leaves you more room for customisation in case there are any specific needs (more likely if you're coding at work or on a non trivial project, vs getting started with the language). Leiningen is an older project - and developed by other folks (not the maintainers of the language) - and once upon a time was what most folks used as there wasn't an "official" solution coming from the language overlords. 🙂 Nowadays (according to the most recent Clojure yearly surveys) most people use deps.edn but there's lots of projects around that are still just fine with Leiningen. If you are familiar with similar tools in other languages, Leiningen will likely appear more familiar to you, whilst deps.edn syntax embraces what you see in Java (thinking of the flags used) and initially might give you some WTF moments, a lot of people complain about this but frankly is not "difficult" at all, it requires a moderate/low level of perseverance to become accustomed to. Personally I'd say that for a beginner of the language itself, Leiningen will "distract" you less, but I'm sure you'll be fine either way (including the usage of your chosen editor).

respatialized 2025-07-19T18:57:38.518689Z

I may be an outlier, but I actually found deps.edn easier to learn (and simpler to use) than lein when getting started in earnest with Clojure

👍 2
➕ 2
Noah 2025-07-19T19:17:08.453469Z

Such great answers 😄 Loving this. deps.edn seems like the simpler way, so I will go with that. It just seems hard to get the ball rolling. Like is there a intro course where you build things slowly? Also considering getting the Alex Miller book.

👍 1
2025-07-19T19:43:09.959219Z

I personally find deps.edn both easier and simpler. Lein has always felt more like a bunch of magic configuration/plugin that I need to Google until it works with no logical way for me to understand what it's doing and why it works.

p-himik 2025-07-19T20:39:31.313379Z

@noahrahimzadagan Have you seen the official guide? https://clojure.org/guides/deps_and_cli

👀 1
gaverhae 2025-07-21T08:07:43.143639Z

@p-himik What would be the simplest clj equivalent to:

lein new t; cd t; lein repl
We're talking about someone trying to learn the language; I don't expect them to care about git dependencies quite yet. Also note how there is nothing in the above command about specifying a version, order of dependencies, or thinking of a name for the project beyond the directory name.

p-himik 2025-07-21T08:15:38.538119Z

It would be just clj. A REPL in an empty project is no different from a REPL in a random directory that has no deps.edn. And if you do need a project, then just mkdir -p t/src; cd t. And if you do need some dependencies, then just vim deps.edn and start adding them there. > there is nothing in the above command about specifying a version, order of dependencies, or thinking of a name for the project The concepts are there, muddying the waters for no benefit, increasing the cognitive load. "I need to add a dependency. How do I do that? Oh, I just open project.clj and add it somewhere there. Wait, what's defproject? What does it do exactly? Why is the second argument to that function is foobar? Oooh, I used foobar a month ago when I just started experimenting, even though I have moved the dir to my-first-web-app the next day. What's "0.1.0-SNAPSHOT"? What's "snapshot"? Do I need that string? There's also a description and a URL, do I need those? License?! Oh god."

gaverhae 2025-07-21T08:20:01.267729Z

clj, as far as I can tell, does not open an nrpel server an editor could connect to.

p-himik 2025-07-21T08:21:16.725679Z

Then it's even easier. If your editor is Clojure-aware, it can probably start the server itself. At least the editors that I've used can do it, without any extra steps. Literally just a push of a button or a few.

gaverhae 2025-07-21T08:35:01.541459Z

> "I need to add a dependency. How do I do that? ..." That's an interesting perspective. From mine, lein new t gives me a well-organized folder, and it's clear where things go. I get stub folders I can build on, I don't need to worry about how to organize the basic things. I can open src/t/core.clj and start typing code. If I need to add a dependency (which, again, learning the language, shouldn't happen right away), I open project.clj, which has a pretty clear name about the fact that it defines my project, and it has an entry called dependencies, which makes it clear that's what I want to change, and there's already an example of how dependencies are specified, syntax-wise. By contrast, "just clj" gives me a REPL, which is fine for about 5 minutes, but it gives me nothing else. I still have to figure out: • What's a project in Clojure? How do I create one? • Where do I put my code? The src folder is implicit, if you have an empty {} deps.edn, and there's no error message if you type clj outside a deps.edn folder, so no indication that you actually want that file. • I need to add a dependency. What's the syntax of deps.edn? I have to discover that's the name of the file I need, where to put it relative to my code, and then write it up myself from scratch, looking up every bit of syntax as I go along. • How do I get my REPL to talk to my editor, or even be aware of my files? Different perspectives, I suppose. I know for me with my background coming to Clojure 13-ish years ago, I would have struggled a lot more with clj, whereas lein was immediately obvious, and I started bemoaing all other languages for not having it. •

gaverhae 2025-07-21T08:36:29.221149Z

I guess it ultimately boils down to "What does Cursive support best?" https://cursive-ide.com/userguide/first-repl.html suggests it can support both, but it does seem to point towards Leiningen "first".

2025-07-21T14:34:19.391749Z

I've found it's hard to say what someone will find easier. It's not universal. For me, I like to understand what's happening and how things work. And it's what I like about tools.deps. there's less magic.

➕ 3
practicalli-johnny 2025-07-20T08:37:59.137159Z

It makes no difference to the Clojure code (and the majority of work to learn Clojure) if you use Leiningen and/or Clojure CLI (tools.deps deps.edn). Leiningen is 'easy' as a first step as you can do lein new and lein repl A Clojure CLI project is simple only needs a deps.edn file containing {} (an empty hash-map), adding Clojure code under src directory. https://practical.li/clojure/clojure-cli/projects/package/tools-build/ are defined in a build.clj file If using Clojure CLI it is useful to have some user level https://practical.li/clojure/clojure-cli/#common-tasks-for-clojure-development. These aliases use community libraries to extend the functionality if the Clojure CLI For example: https://github.com/practicalli/clojure-cli-config

gaverhae 2025-07-20T10:02:12.425559Z

I would recommend starting with Leiningen, but moving to Clojure CLI soon-ish. Leiningen is first and foremost a declarative dependency management system. If all you need is "I want a clojure project with these dependencies, and give me a REPL to go with it", Leiningen is great. The main advantage of the Clojure CLI is that it lets you define your build in Clojure. As a beginner learning the language, you don't need to define a build, and having to do it in Clojure may not be seen as an advantage as it basically means you have to use the language to set up your ability to learn the language. For the first few sessions, you can likely get away with one invocation of lein new, and then just keep a lein repl running. Your editor is very likely going to connect seamlessly to the running repl, or detect it's a Leiningen project and start its own repl. The most important thing you want is a connection between your editor and your repl; you need to be able to, in your editor, select a form (a balanced pair of aprentheses) and "send" it to the REPL, getting the result immediately. I'm not a Cursive user myself so don't know the details, but try to look up what keybindings let you do that. I'd use Leiningen for as long as you can get away with no plugin, and then switch to Clojure CLI as soon as you feel the need for customization.

p-himik 2025-07-20T11:21:05.600139Z

If all you need is "I want a clojure project with these dependencies, and give me a REPL to go with it", Leiningen is great.deps.edn is not worse here by any means. Even better, because you don't need to: • Think of a name of your project (the name of the dir does not count since it doesn't become a part of the repo) • Specify a version • Dread Git dependencies • Deal with different orders of dependencies resulting in different outcomes > I'd use Leiningen for as long as you can get away with no plugin, and then switch to Clojure CLI as soon as you feel the need for customization But unless I'm missing something, deps.edn already has all the capabilities of of Leiningen with no plugins, so what would be the point of sticking to Leiningen in this case at all, if there are reasons to switch away from it and no reasons to switch to it?

st 2025-07-20T15:25:06.415319Z

On deps.edn side 😉 This video helped me: https://www.youtube.com/watch?v=8aCO_wNuScQ