For macOS/Linux, I don’t think installing clojure
/clj
is any more complex than installing Ruby/Python/etc – although I guess on Linux folks might lean toward apt
/yum
and that’s a much harder path to walk given the “everything must be compiled from source” mentality of most of the Linux package managers?
For Windows, yes, installation is still a fraught process (and discussions continue in #clj-on-windows on Slack about that today!). For developers on Windows, I always suggest WSL2 so that you’re back in the “macOS/Linux” world and most Clojure tutorials/books etc will “just work” but now you’re drifting further away from how to install “a language”.
As for going to a more involved program, you can “grow” your Hello, World! one step at a time – I just don’t think tutorials really cover this.
So we have hello.clj
and we run it with clojure -M hello.clj
(to avoid the warning).
Now we can add deps.edn
with, say, {:deps {org.clojure/data.json {:mvn/version "0.2.6"}}}
and update hello.clj
to have:
(require 'clojure.data.json)
(println (clojure.data.json/write-str {:hello "world"}))
and you can still run it with clojure -M hello.clj
and it will fetch data.json
and run the code.
Then you could explain ns
and change that to:
(ns hello
(:require [clojure.data.json :as json]))
(println (json/write-str {:hello "world"}))
And when you finally need multiple namespaces, you can explain the src
tree convention and move to something like:
src
|- hello.clj
+- world.clj
Now, that’s all just the files side of things – but it’s a lot more like how most other language tutorials work I think? The next step is the most important for beginners, IMO, and that’s to get an editor up and running with a REPL and learn to eval code from source files via the REPL rather than typing into it. I think we do a poor job there.
And then testing is, I guess, the next step which adds aliases and more dependencies/tooling, and then learning how to run tests via your editor and/or from the command line.