Chapter 5. How to Use Clojure Projects and Libraries

Over the past few chapters, you have grown strong in your Clojure knowledge. You now know the fundamentals of the language, how to shape and control code in a functional way, and how to interact with the real world. So far, we have been working with short code snippets in a stand-alone REPL. Now, we will start building a project with Clojure.

In this chapter, we are going to be creating a Clojure project using the Leiningen build tool. Along the way, we are going to learn about how to run Clojure programs and test them, as well as how to manage and use libraries in our project.

Because we are going to be working with files and a directory structure, you might be wondering: What editor do I use for Clojure?

Getting Set Up with a Clojure Editor

There are many different choices for editors today. The best one for you is quite a subjective decision. It is wise, however, to try not to learn too many things at once. Try to use an editor or plug-in that you already know. Later, after you become more comfortable with Clojure, experiment with other editors and see what you like best. Here are a few of the most common editors/plug-ins for Clojure:

IntelliJ

There is a very nice plug-in for the ItelliJ editor called Cursive. It has quite a few good editing features for Clojure.

Eclipse

The Eclipse editor also has a good plug-in called CounterClockwise. It has good, solid Clojure support.

Vim

If you are a vim user, you should check ...

Get Living Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.