Libraries available for use with Clojure include:
as well as:
(Installation and usage is covered in the next chapter.)
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”.
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).
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.
Clojure also has a number of standard extra libs (“contrib” libraries) available, which are not distributed with Clojure proper. They all:
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 |
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).
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:
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.
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.
You can use Java libraries even if they’re not listed at Maven Central, but doing so is beyond the scope of this document.