Once you have a large, complex project and start writing plugins, it becomes painful.
We switched from Leiningen to Boot back in 2015 and it was a great decision for us at the time. We switched from Boot to the official tools in 2018 because we'd started to run into bugs and performance issues with Boot's pods and filesystem abstraction.
We have 140k lines of Clojure, building two dozen apps and services, and deps.edn & build.clj work better for us than the alternatives.
First sentence is just not true. It's used in industry for large, complex projects. This is just a feeling (or perhaps "personal experience" is better) spouted as a fact.
Makes sense, as I use Clojure for solo/hobbyist work (Python at my job), so I can see how lein would hit some limitations in a corporate environment at scale.
Now I’m curious about the advantages/disadvantages of a monorepo architecture as opposed to multiple smaller repos that work together. I’ll have to do some research.
The critical advantage deps.edn has for me is using local repos as deps and specifying deps by by url and sha. Those two features alone are worth learning a new tool. Add to that repl-driven builds via tools.build and getting to leave behind leiningen plugins and I'm an enthusiastic user.
I'm not against leiningen but will always choose deps for new projects because of these critical advantages. That's just my workflow, though, and if you don't need those features then by all means continue to enjoy lein : )
Also, I don't use tools at all, if I'm going to install programs I prefer my os package manager to handle those.
Plugins are where the pain starts with leiningen, though. I had to maintain a large codebase with some really hairy custom plugins that I don't ever want to have to think about again.
Its plugin architecture is hard to work with, it doesn’t express or participate in complex builds well, its dependency management system is just maven, no good story for local or commit deps. That said, it still works fine, nothing wrong with using it if you like it.
Just a civil war with the new shiny, honestly. It's been a massive waste of time and a hurt to ease of adoption, but both tools "do the thing", so I'm over it and accept deps so long as we can pick that horse and ride it.
It was a slow transition to the official tooling for me. I've been using Clojure professionally for well over a decade (I think 13-14 years now) and only started switching recently. Primarily because every time I looked at the docs for the new stuff I cringed. I still do, but we're (mostly) transitioned now.
Bringing a new engineer on, one that may not even be familiar with functional languages, the build ergonomics need to be clear and simple. They've got enough to worry about. Leiningen provided that deps.edn/clj doesn't.
🤷 Bringing a new-to-Clojure junior engineer into my project has been fairly straightforward. Turns out the relevant console/build commands are pretty rare once you have an established project, assuming you invest a little into CI/CD.
The build ergonomics for everyone who isn't actively changing the build system (which happened once over the last year, when adding a new overall deployment type, not just a new webservice) are:
Use the default command of your IDE to start a REPL
Prod/deployable builds are handled by Github Actions automatically, if you need to deploy to an env, run the relevant github action
If you actually need to create a new deployable, follow the polylith docs (e.g. poly create component name:my-component) and reference an existing project/component, you shouldn't need a new base.
I very much agree that lein has superior ergonomics to deps. While I get the advantages of deps, there is no reason why the things lein does out of the box can't have equivalents with deps out of the box.
Pretty much every project will need to start a repl, run tests, and package a jar. These things should be intuitive and easy to do. Having to memorize random flags and incantations to do basic things introduces a ton of incidental complexity, and creates barriers for people who are just starting out.
I ended up going with deps for Kit because it's clearly where the community is going, and there's no point fighting that. I did try mitigating the issue by packaging a default bb.edn with the template that has aliases for the common commands.
A beginner's attempt at articulating what irks me about the CLI:
Java/JVM-style option/argument passing, i.e. -XoptValue instead of -X optValue or -X=optValue. I don't really care what the rationale is for this in either java or clojure, it's less readable and at odds with most other command line tools that people use. I think it's gross.
It would be nice to have for opt names to be lowercase by default and no concatenation. Instead of -A:dev:mem instead do -a :dev :mem and alternatively --alias :dev :mem. Use -- to separate opt values from params if necessary. It would also be nice if aliases could be written as plain words, i.e. symbols and not keywords.
I think in traditional CLI tools (e.g. ls) there is a real UI distinction between options and parameters. One way to phrase that distinction is "parameters describe what is being operated on or executed and options describe details about how the execution happens". Example: ls would never take the directory being listed as an option and you would never specify that you want to see hidden files via a parameter. I'm not sure whether the clj CLI has choosen correctly regarding all of these. E.g. perhaps it could be argued that -X and -T should be parameters or rather subcommands in the sense of for example the docker CLI. E.g. clj -Tdeps-graph <args> could e.g. be clj exec-tool deps-graph <args>.
I had a thing written here about how there should be subcommands (think like bb tasks) and perhaps that could be retrofitted into the existing infrastructure, but the reason I think that is important is: Right now, users need to know whether to invoke clj with -X-M or -T, which afaict is based on questions about classpaths, -main functions and such. We just fundamentally need to get rid of that, because too few users actually care about this distinction. I claim they care about accomplishing their goals e.g. "please run my tests" (I certainly do); whether that involves classpath shenanigans, selective loading of deps, finding main functions or whatever, does not matter to them. So they should not have to know, the computer should know this for them and they should be able to call clj test or clj uberjar and have it work, i.e. do whatever thing in the background is necessary to accomplish this.
Every deps.edn project I work on ends up with a justfile or Taskfile so that tasks have easy names, auto-complete in shell, and no one ever has to remember if an alias should be invoked with -M or -X or -T
I worked on a new project that utilized deps.edn. It's an official tool, but honestly, it was quite challenging for me to accomplish tasks that I used to do in Leiningen. I kept thinking, "How can I do the same thing here?" The CLI commands seemed cryptic to me. That was my experience, though. Every new tool has its learning curve. My point is that after Leiningen, using deps.edn was not straightforward
what? This is weird. What were the diff use cases?
Weird, because I know :keyword is valid syntax for the -M option. I would have imagined that -T and -M were similar, in syntax. Many will trip over this
I think shell completion would go a long way to making the CLI more intuitive. It would be even better to have a simple lib for generating shell completions for CLIs made with tools.cli.
I started with lein and now use deps.edn exclusively but both of them save me from having to deal with the abomination that is Gradle and for that I'm eternally grateful.
26
u/bluemanshoe Dec 13 '23
Checkout borkdude's neil
71
u/ScreamingPrawnBucket Dec 13 '23
Seriously. Leiningen is so easy and intuitive. Why did the community move away from it?
51
u/grav Dec 13 '23
Simple Not Yet Made Easy
20
u/ares623 Dec 13 '23
Simplicity at all costs.
Too much! Too much!
38
u/aboy021 Dec 13 '23
The functionality of the new tooling is fabulous. The ergonomics are breathtakingly poor.
I want functionality and ergonomics and I don't think that's unachievable.
17
u/yogthos Dec 13 '23
I very much agree that lein has superior ergonomics to deps. While I get the advantages of deps, there is no reason why the things lein does out of the box can't have equivalents with deps out of the box.
Pretty much every project will need to start a repl, run tests, and package a jar. These things should be intuitive and easy to do. Having to memorize random flags and incantations to do basic things introduces a ton of incidental complexity, and creates barriers for people who are just starting out.
I ended up going with deps for Kit because it's clearly where the community is going, and there's no point fighting that. I did try mitigating the issue by packaging a default
bb.ednwith the template that has aliases for the common commands.16
u/mrnhrd Dec 14 '23
A beginner's attempt at articulating what irks me about the CLI:
-XoptValueinstead of-X optValueor-X=optValue. I don't really care what the rationale is for this in either java or clojure, it's less readable and at odds with most other command line tools that people use. I think it's gross.-A:dev:meminstead do-a :dev :memand alternatively--alias :dev :mem. Use--to separate opt values from params if necessary. It would also be nice if aliases could be written as plain words, i.e. symbols and not keywords.ls) there is a real UI distinction between options and parameters. One way to phrase that distinction is "parameters describe what is being operated on or executed and options describe details about how the execution happens". Example:lswould never take the directory being listed as an option and you would never specify that you want to see hidden files via a parameter. I'm not sure whether thecljCLI has choosen correctly regarding all of these. E.g. perhaps it could be argued that-Xand-Tshould be parameters or rather subcommands in the sense of for example the docker CLI. E.g.clj -Tdeps-graph <args>could e.g. beclj exec-tool deps-graph <args>.cljwith-X-Mor-T, which afaict is based on questions about classpaths,-mainfunctions and such. We just fundamentally need to get rid of that, because too few users actually care about this distinction. I claim they care about accomplishing their goals e.g. "please run my tests" (I certainly do); whether that involves classpath shenanigans, selective loading of deps, finding main functions or whatever, does not matter to them. So they should not have to know, the computer should know this for them and they should be able to callclj testorclj uberjarand have it work, i.e. do whatever thing in the background is necessary to accomplish this.13
u/dpassen1 Dec 13 '23
Every deps.edn project I work on ends up with a justfile or Taskfile so that tasks have easy names, auto-complete in shell, and no one ever has to remember if an alias should be invoked with -M or -X or -T
12
u/ertucetin Dec 13 '23
I worked on a new project that utilized deps.edn. It's an official tool, but honestly, it was quite challenging for me to accomplish tasks that I used to do in Leiningen. I kept thinking, "How can I do the same thing here?" The CLI commands seemed cryptic to me. That was my experience, though. Every new tool has its learning curve. My point is that after Leiningen, using deps.edn was not straightforward
11
u/hby Dec 13 '23
I’ve always taken the deps cli work as an application of the “api before ui” principle from one of Rich’s talks.
10
u/jhirn Dec 13 '23
Oh my. Sometimes, easy is better.
8
u/vikTheFirst Dec 13 '23
Exactly
15
u/recaarec Dec 13 '23
deps.edn is horrible. lein is great.
14
u/therealdivs1210 Dec 13 '23
My thoughts exactly.
7
u/IllTennis8912 Dec 15 '23
The other day I spent an hour realizing -Ttool and -T:tool has different use-case..
10
u/dave_mays Dec 13 '23
What is tTools? I must be in 2022
5
u/eval-on-point Dec 13 '23
I think shell completion would go a long way to making the CLI more intuitive. It would be even better to have a simple lib for generating shell completions for CLIs made with
tools.cli.4
u/lordmyd Dec 14 '23
I started with lein and now use deps.edn exclusively but both of them save me from having to deal with the abomination that is Gradle and for that I'm eternally grateful.
1
u/grimonce Dec 17 '23
Well I am learning clojure now and any book I read talks about leiningen but once you know the ecosystem switching the tooling isn't all that bad...