Pedro Delfino
Pedro Delfino

Reputation: 2711

What is the benefit of having a Clojure project before starting the REPL? Why Cider keeps asking and nudging the user about it?

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

Upvotes: 1

Views: 278

Answers (2)

dorab
dorab

Reputation: 807

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.

Upvotes: 1

Gwang-Jin Kim
Gwang-Jin Kim

Reputation: 10010

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.

Upvotes: 0

Related Questions