1

I am using Emacs and every time I start a Clojure REPL with cider-jack-in , the minibuffer echoes the following:

Are you sure you want to run `cider-jack-in' without a Clojure project? (y or n)

I have a prior experience with Common Lisp and Slime. In this other lisp ecosystem, there is not such a thing. You just start Common Lisp without questions asked.

I do not get the purpose of this message from Cider. Probably, because I am missing something.

It is important to highlight that I do know how to create a Clojure project using lein command. I just do not get its relevance.

What am I missing for not using a Clojure project before starting the REPL? Why is it so relevant?

What is the downside of developing a Clojure program with the .clj file, the REPL, doing some interactive programming, and re-compiling things as the program evolves with editions?

Just preventing problems with namespace?

Thanks

Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
  • 2
    One potential issue is having to deal with the classpath. It's much harder to specify dependencies without having a proper project. Another issue arises when you need to deal with multiple files - `:require` needs a proper directory structure. – Eugene Pakhomov May 18 '22 at 17:06

2 Answers2

1

The main reason for using a "project", whether it is via a deps.edn file (for Clojure CLI tooling) or a project.clj file (for lein), is to provide the dependencies and hence the CLASSPATH. Since Clojure runs on the JVM, the CLASSPATH has to be set before the Java process is started. As an aside, this is not strictly true, but I'll ignore that complexity for now. The CLASSPATH is used by the JVM to find and then load classes during runtime.

If you're not using any dependencies then you can probably get away with not using a project.

I use emacs with cider and the Clojure CLI tooling myself. You might also want to look into the inf-clojure emacs package.

dorab
  • 807
  • 5
  • 13
0

I am also coming from Common Lisp to Clojure and was confused a lot at the beginning.

And we use lein new because BraveClojure etc. shows this as the only way. Despite of its truths, it is too old. The Clojure community should write more up-to-date tutorials and books.

There is e.g. boot - the other build tooling tool than lein: https://github.com/boot-clj/boot

Short intro: https://jjmojojjmojo.github.io/boot-getting-started-with-clojure-in-10-minutes.html

Which allows you to start a repl with $ boot repl a repl with boot.user as the namespace similar to CLUSER.

It is as powerful as lein.

And for command line scripting, there is babashka https://github.com/babashka/babashka which is interpreted Clojure for scripting - callable even from the command line.

Gwang-Jin Kim
  • 9,303
  • 17
  • 30
  • 4
    Boot is very much the minority tool in the Clojure world and isn't supported at all by a lot of other tooling these days. The alternative to Leiningen that is worth learning is the official Clojure CLI tooling: https://clojure.org/guides/deps_and_cli – Sean Corfield May 18 '22 at 19:26
  • 1
    I found boot quite cool. - lightweight, and you can define and even build from the repl. You can't compare it with official Clojure CLI. – Gwang-Jin Kim May 18 '22 at 19:33
  • @SeanCorfield, do you use Emacs? Which editor? – Pedro Delfino May 18 '22 at 20:05
  • 1
    I would also strongly support Sean's position. Either use `lein`, or, preferably, use the clojure CLI tooling. I use emacs with Cider and the Clojure CLI tools. You might also consider Sean's `clj-new` https://github.com/seancorfield/clj-new or better still, `deps-new` https://github.com/seancorfield/deps-new as a replacement for `lein new`. – dorab May 18 '22 at 22:04
  • 1
    Guys, I use `lein` and `emacs` too. But when I want to fire the repl to just quickly try out stuff, I use `boot`. It is like with Common Lisp, I use `emacs` with `slime` running `sbcl` (and since some time via roswell) when I program with Common Lisp. But when I want to quickly try out stuff, I fire `CLISP` and try it out there while keeping track of the code on a `gedit` sheet, manually indenting the code. It is a habit from my very early Lisp learning time, I guess. I think one can use different tools for different situations. Sometimes I use even `$ rlwrap clojure` . – Gwang-Jin Kim May 19 '22 at 03:13
  • 1
    `lein` is still the go-to tool for developing clojure project (it's not "old" or "deprecated"), especially for beginners (deps.edn is a higher barrier for absolute beginners imho). Boot falls into the same category, but has the disadvantage, that the community moved on - so less users, less users to ask on problems etc. Also: `lein repl` works outside of projects; `rlwrap clojure` is `clj` from CLI-tools. – cfrick May 19 '22 at 04:43
  • 2
    @PedroDelfino I've used a lot of different editors over the decade that I've been doing Clojure in production. I have used Emacs in the past (stretching back to the 17.x days!). I'm currently using VS Code/Calva with Portal for data visualization. The official tools -- the CLI plus tools.build -- allow fully programmatic builds via the REPL: that's how I work all-day, every-day. We switched from lein to boot in 2015 and boot to CLI in 2018 at work. – Sean Corfield May 19 '22 at 20:10