Leiningn, Boot, the command line tool: starting from scratch

I’ve dabbled in Clojure some years ago

Now I’d like to set up a dev environment from scratch on a Ubuntu 22.04.2 LTS machine

I see there are 3 options

Leiningen
Boot
an official (?) command line tool

which one should I use and why ?

what are the pros and cons of each one ?

Are they meant for different scenarios, kind of user, whatever ?

Thanks in advance

Many people find lein easier to use but I personally find that the deps.edn based tooling is more flexible when it comes to development (local and git dependencies, programmatic builds). Both are good options, but boot isn’t actively maintained anymore (I think, somebody correct me if I’m wrong).

If you want to have a quickstart with the official CLI, take a look at my blog post here:

https://blog.michielborkent.nl/new-clojure-project-quickstart.html

5 Likes

In short:

  • use Leiningen for a self-contained tool (used for most existing Clojure projects)
  • use Clojure CLI for flexibility and a wide range of community tools (growing use for new projects)

Ultimately the tooling makes no difference to the Clojure code that is written, so are free to use any of these tools

Leiningen has long been the main project automation tool for Clojure. Leiningen is self-contained and generally doesn’t require any other tools (although it has a plugin system and can be extended with aliases

Boot was designed to be a programmatic approach to managing projects, writing Clojure code to carry out tasks. Boot did not get wide adoption in the Clojure community

Clojure CLI is one of several tools created by the Clojure team. Clojure CLI is designed to run Clojure programs (including a repl) and manages Maven and Git depencies in order to run Clojure.
Clojure CLI is easily extended via aliases which reside in the project or user configuration. Aliases can add libraries or define tools that extend the features available with Clojure CLI
tools.build also helps define how project are built into jars and uberjars

Practicalli Clojure - Practicalli Clojure is a practical guide to using Clojure CLI and provides a wide range of aliases in the Practicalli Clojure CLI Config

Practicalli Clojure also includes install instructions and an overview of Clojure aware editors

2 Likes

Summary of prior discussions (with a focus on the “why” of the existence of tools.deps and the CLI) here.

Lein has over a decade in prior-market share, so a lot of materials are written with it in mind. I still use it for the majority of projects, although the cli is encroaching (voluntarily and otherwise) on my work. There are plugins for lein that patch in features I would find attractive with the cli (git deps specifically), but it’s not “quite” the same.

The cli/tools.deps still has the glint of new, and like boot (which is effectively defunct but still found in some legacy projects), some folks were quick to jump on since it offered flexibility by way of a direct path to clojure-programmable builds. That also came with some dev churn as the tooling was being dog fooded by Cognitect, but I think it’s relatively stable now though. If you prefer/need to specify your builds (maybe edging in on devops style stuff or make files or any other “flexible” build process with unique requirements), then the cli is probably much more compelling. If you don’t need that flexibility though, then perhaps the built-in suite of tasks in lein is easier.

The CLI has a bit of (IMO) Byzantine set of switches that define a pretty robust API though so you can do a bunch of stuff in the ream of unix style commands. That includes simple scripting with a single source file. lein tends to push you into making a project, although there are plugins that aim to facilitate scripting (again not “quite” the same though).

I think the not so subtle community pressure seems to tend toward pushing on-boarding people with the CLI , since it bears the mark of Official, it’s more flexible, etc. I see this period as - at best - a transitory period with a split brain (as opposed to the python 2/3 schism). A great many projects remain managed/developed in lein (given the knack for stability and backwards compatibility, some are effectively frozen). Many new projects are in tools.deps/tools.build. So if you want to work with source repositories of any arbitrary project, you would still need both to do so (in theory boot could even creep up, but it’s rare). A great many projects are also “only” deploying as git dependencies (e.g. source code repositories on github or elsewhere), as opposed to resolved jar artifacts on clojars/maven (the common deployment model from “before”). I think lein with lein-git-down can handle this emergent dev style fairly gracefully, but tools.deps does it out of the box. Many libraries (the vast majority I use) seem to still deploy as jar files to clojars/maven, which can be resolved by either platform.

Most of the documentation for tools.deps/CLI will be online and decoupled from legacy clojure materials. So if you pick a book up, chances are you are probably going to have to toss out all the lein walk through and project examples and supplement that with online resources around tools.deps and the cli. If you learn clojure from more recent blog posts, online tutorials, or e-books like John’s, then you will likely find tools.deps/CLI as the default.

4 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.