A Brief Beginner's Guide To Clojure
← prev | next →     Top-level ToC     /libs-available.html     (printable version)

Libraries available for use with Clojure include:

  • clojure.core (the fundamental built-in library of the Clojure language)
  • its own standard libraries (these ship with Clojure)
  • the contrib libraries (also standard, but they don’t ship with Clojure)

as well as:

  • 3rd-party Clojure libs (available via Clojars)
  • Java standard class library (comes standard with Java)
  • 3rd-party JVM libs (available via Maven Central)
  • other Java libs

(Installation and usage is covered in the next chapter.)

1 Synopsis

type of lib namespace standard? ships with Clojure/JVM? location
core clojure.core built-in
standard lib clojure.* included with Clojure
contrib clojure.*   projects at github, jars via Maven Central
3rd-party clj (various)     projects at github, jars via Clojars
Java std lib (various) included with Java
3rd-party JVM (various)     jars via Maven Central

Note that the API docs for the built-ins, standard library, and contrib are all at http://clojure.github.io/.

Also, it appears that the built-ins + standard lib are sometimes referred to collectively as the “core libraries”.

2 clojure.core

These are Clojure’s built-ins, for example, map and filter. They are in the clojure.core namespace (but for convenience, and as a special case, Clojure makes them always available to you by their short unqualified names).

3 Standard Library

In addition to clojure.core, Clojure comes with a number of standard libraries. They’re all listed (along with their documentation) at http://clojure.github.io/clojure/index.html. Their namespace names all start with “clojure.”, for example, clojure.test and clojure.pprint.

If you download the Clojure release and look in its “clojure-i.j.k/src/clj/clojure” dir, you can see the source code files for these libs.

4 Contrib

Clojure also has a number of standard extra libs (“contrib” libraries) available, which are not distributed with Clojure proper. They all:

  • are listed under “Clojure Contrib Libraries” at http://clojure.org/api/api.
  • live at github as separate projects under the same “clojure” org as Clojure itself.
  • have dots in their project names (making their project names look like namespace names)
  • have namespace names that start with “clojure.” (just like core and standard libs) and go like “clojure.{contrib-project-name}”. For example, clojure.math.combinatorics and clojure.java.jdbc.
  • have documentation available at http://clojure.github.io/.
  • are owned by their author as well as by Rich Hickey, as per the Clojure CA (“Contributor Agreement”).

Some contrib library naming conventions:

Name prefix Description
core. language extensions
java. libraries which wrap existing Java libs
tools. for Clojure tooling
data. for working with various data formats and structures

5 Libraries from Clojars

There are many libraries available for Clojure at Clojars. Clojars is the “CPAN for Clojure”, except that only basic information about a given project is displayed at its clojars page (namely: a short description, project url, and some technical info necessary for using the project). To read more about a given project at Clojars, follow the link on its Clojars page (which usually leads to its github project page displaying the project README).

If a given project is hosted at github, but there’s no github link at its clojars page, you can help the community by contacting the author and letting them know their project may be missing a “:url” option in its project.clj file (more details on what that means in the next chapter).

Some libraries at Clojars may also be part of an “umbrella project” (for example, Clojurewerks).

5.1 Some Notes on Library Naming

Although Clojure libraries often have interesting and unique names, it’s not uncommon to see libs named either with a “clj-” prefix or a “-clj” suffix. You’ll sometimes see this when:

  • the given Clojure lib wraps a Java lib and the author wants to re-use the Java lib’s name, or, when
  • the Clojure lib implements a well-known spec/standard and the author wants to re-use the spec’s name).

6 Java Standard Library: JDK

Clojure can, of course, use Java’s built-in “standard class library”. See the Java documentation for what’s available.

Java interop is fairly simple (though not discussed in this guide), and — as with the Clojure standard libraries — there’s no extra installation required since you already have Java installed.

7 Libraries from Maven Central

There are also many JVM libraries available for use by Clojure at Maven Central. Maven Central is the “CPAN for the JVM”. These libs are typically — though not necessarily — written in Java. (Incidentally, the contrib libraries are actually hosted at Maven Central rather than at Clojars.)

To find the libraries you need, you might browse around at:

Those collections are large, and may host both libraries and tools (with some tools containing component libraries which you might find useful as well).

Incidentally, the Clojure on JBoss app server is Immutant.

8 Other Java Libraries

You can use Java libraries even if they’re not listed at Maven Central, but doing so is beyond the scope of this document.