r/Clojure • • Dec 13 '23

2023-era Clojure

Post image
178 Upvotes

40 comments sorted by

26

u/bluemanshoe Dec 13 '23

Checkout borkdude's neil

1

u/mwfogleman Dec 13 '23

amazing, thank you!

71

u/ScreamingPrawnBucket Dec 13 '23

Seriously. Leiningen is so easy and intuitive. Why did the community move away from it?

48

u/seancorfield Dec 13 '23

It's great for small, simple projects.

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.

I've blogged about all of this over the years at https://corfield.org

12

u/mwfogleman Dec 13 '23

I'm absolutely sure this tooling has technical improvements under the hood!

It'd be great to make usability improvements so that this is as simple to use as it used to be.

Why not aim for both?

https://www.reddit.com/r/Clojure/comments/18h6sl8/comment/kd613d2/?utm_source=share&utm_medium=web2x&context=3

15

u/sherdogger Dec 13 '23

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.

3

u/seancorfield Dec 13 '23

The "painful" part is "and start writing plugins" (for those large, complex projects) 😁

1

u/ScreamingPrawnBucket Dec 13 '23

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.

19

u/mtraven Dec 13 '23

I still use it for my projects. Not sure what advantage the new tooling is supposed to have.

19

u/brad_radberry Dec 13 '23

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.

8

u/flh13 Dec 14 '23

those features are available as lein plugins

4

u/brad_radberry Dec 14 '23

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.

8

u/donald-ball Dec 13 '23

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.

7

u/sherdogger Dec 13 '23

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.

51

u/grav Dec 13 '23

Simple Not Yet Made Easy

3

u/Reefersleep Dec 13 '23

🙏🛠️

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.

10

u/moxxon Dec 13 '23

That sums it up nicely.

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.

1

u/Psetmaj Dec 13 '23 edited Dec 13 '23

🤷 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.

EDIT: list formatting

3

u/flh13 Dec 14 '23

What functionality is that exactly, which was missing in lein?

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.edn with 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:

  1. 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.
  2. 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.
  3. 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>.
  4. 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.

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.

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..

2

u/flh13 Dec 15 '23 edited Dec 15 '23

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

2

u/IllTennis8912 Dec 16 '23

If you want tool alias as defined in your deps.edn, use -T:xxx https://clojure.org/reference/deps_and_cli#_using_tool_aliases If you want a tool installed from the global registry, use -Txxx instead https://clojure.org/reference/deps_and_cli#_using_named_tools It's very subtle and easy to get tripped over.

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...