News for hackers. Stuff that matters.
Re:Clojure 15th Anniversary: A Retrospective by roenxi on Saturday October 22, 2022 @04:11AM (#33296442)
deps.edn isn't solving the same problem as lein. Lein you install it, run "lein" and it starts telling you what to do to get a running Clojure project.

Deps you install Clojure and ... no hints how to get to a running project.

"touch deps.edn"? Still no hints how you get from here to functioning clojure dependencies. It isn't a YAML file. Isn't JSON. No template.

Read the reference page (https://clojure.org/reference/deps_and_cli)? We quickly learn that you can execute a function by invoking "clojure [clj-opt] -X[aliases] [a/fn] [kpath v] kv-map?". Still not much closer to installing a dependency, a lot of people probably give up here.

Oh, there is a guide! Read the guide (https://clojure.org/guides/deps_and_cli). Now we get to our first dependency.

Lets add a 2nd one!

    {:deps
     {com.github.seancorfield/next.jdbc {:mvn/version "1.3.834"}}
     {clojure.java-time/clojure.java-time {:mvn/version "1.1.0"}}}

    $ clj
    Error building classpath. Error reading edn. Map literal must contain an even number of forms (~/deps.edn)
This is a pretty plausible on-boarding with deps. Beginners should be using lein, it is a lot more forgiving and doesn't leave people staring at an error message feeling stupid after 10 minutes being confused about what the docs are trying to prepare them for. It'd be good to include something like that in the default distribution so they don't have to figure that fact out by failing a bit with deps.
Re:Clojure 15th Anniversary: A Retrospective by dig1 on Saturday October 22, 2022 @06:03AM (#33296901)
This! Leiningen is Maven for Clojure and tools.deps is Ant, for those who used them in Java-land. tools.deps can't build your project without a separate library called tools.build, just like Ant can't pull down dependencies without Ivy.

Maven (like Leiningen) bundles all of that in a single tool, plus adds tons of more options. On top of that, you have a plugin for almost anything.

Re:Clojure 15th Anniversary: A Retrospective by cutler on Saturday October 22, 2022 @08:52AM (#33297926)
Trouble is it requires a separate JVM instance to run.
Re:Clojure 15th Anniversary: A Retrospective by dig1 on Sunday October 23, 2022 @05:17AM (#33305662)
No, it doesn't, if you run it with "trampoline" option. You can also have a cached trampolines for even faster startup. Check the docs ;)
Re:Clojure 15th Anniversary: A Retrospective by casion on Saturday October 22, 2022 @07:26AM (#33297367)
There's no need for a "project" to learn clojure. By time you get to the point of wanting one, you should probably know what a map looks like. You inserted extra {} in your example, a similar mistake would also break a JSON file.

Or you could read the guide on the website: https://clojure.org/guides/deps_and_cli

Re:Clojure 15th Anniversary: A Retrospective by CraigJPerry on Saturday October 22, 2022 @07:35AM (#33297408)
Yeah this is grim.

There is https://github.com/practicalli/clojure-deps-edn which solves this but it’s not linked to from any official docs which seems a miss to me. As well as the config and full documentation, it also comes with a video walking you through a demo of all the features.

Re:Clojure 15th Anniversary: A Retrospective by NoahTheDuke on Saturday October 22, 2022 @07:17PM (#33303092)
I roughly agree with you but in your deps.edn example, how would you like the tool to respond? Your map/dictionary/object has an uneven number of forms, so what else would you like it to say?
Re:Clojure 15th Anniversary: A Retrospective by roenxi on Saturday October 22, 2022 @09:19PM (#33303672)
The mistake the programmer has made is copy-pasting a line that wasn't meant to be copy-pasted. The error is gobbledegook about implementation details of the deps file, saying a map is malformed in a file that has 5x maps and not much more to bring in 2 dependencies. The error message itself isn't the problem as much as the spartan design of the deps file that leads rookies into screwing up in a way that isn't obvious what went wrong. There are a lot of easy syntax errors here that give no useful error message explaining what went wrong. There isn't even a hint how many maps are needed to bring in those 2 dependencies (turns out, 4). It'll bleed newbies if they try to figure out this file.

I think their should be a "lein-for-deps-template" that subtly guides people in the right direction by starting the project up with 2+ dependencies. Lein dodges this by using a list-of-list data structure where this mistake is harder to make (copy and pasting stuff in brackets is the right strategy in lein) and there is much more boilerplate in a project.clj to hint what our aspiring Clojure programmer needs to fill in.

My problem here is that the entire way through that story, at no point is there a simple prompt in the official reference documentation telling people what a deps file with multiple dependencies should look like. Even finding the examples of 1 dependency is quite deep in and seems to be an advanced topic (you'll note the sibling comment that considers dependencies an advanced topic for people who already know the language well enough to reflexively get maps right, and it says a lot about the actual complexity of deps that the official guide to installing dependencies thinks 2x dependencies is out of its scope).