The most popular variant of Clojure runs
on the JVM
(Java Virtual Machine).
Because Clojure embraces whichever platform it is running on,
this variant has inherited a wealth of Java-related concepts,
jargon, libraries, tooling, etc.
So, in order to be effective in using Java-based Clojure,
aspiring developers need to learn some Java concepts.
This page attempts to present a minimal set,
suitable for use as a starting point.
Mike Meyer's blog post, A Guide to Javaless Clojure
contains detailed information on installation and setup of Clojure,
but it is based on raw Unix commands, etc.
These days, the Golden Path has shifted to a combination of:
- an enhanced text editor or an IDE (Integrated Development Environment)
- Leiningen - "for automating Clojure projects without setting your hair on fire"
- nREPL - a client/server "network REPL" that provides an API, tools, etc.
This page assumes that you are using such a combination.
So, we'll look at a few implementation issues,
then jump past all of the details that this approach handles for us.
Most text editors provide only limited support
(eg, code folding, syntax highlighting) for programming languages.
However, a number of Clojure plugins are available
and healthy competition is going on regarding feature sets, etc.
- Adobe Brackets is a web-based text editor that is currently in early development.
The clj-brackets extension provides REPL support for Clojure.
- Emacs began as a text editor, but its extensibility and wealth of plugins now qualify it as an IDE.
Developers who prefer a more integrated approach generally
use an IDE
Here are some popular (or promising) options:
- Emacs is the dominant Open Source IDE for Lisp. There are a number of plugins
(eg, clojure-mode, nrepl.el, ParEdit). Emacs is famously powerful and infamously
complex, so YMMV...
- Light Table is a very interesting attempt to create a totally new IDE for Clojure
(among other languages). It is still in Alpha, but is definitely worth watching!
Leiningen is very analogous to some parts of Ruby on Rails
For example, it:
- automates common tasks (eg, builds, downloads)
- supports a standardized directory tree layout
- uses conventions and declarative configuration
As the Leiningen
Leiningen offers the easiest way to get started with Clojure.
With a focus on project automation and declarative configuration,
it gets out of your way and lets you focus on your code.
In particular, Leiningen deals with the infamous complexities
of build systems such as Ant
So, install it, use it, and send Phil Hagelberg a nice note.
Sadly, there are a few remaining Java concepts to learn. Here goes...
Clojure and Java archives are available from several sites:
(generally containing Leiningen
are very popular as a way to distribute source code.
are the dominant archive formats for distributing production software:
... JAR (Java ARchive) is an
archive file format
typically used to aggregate many
Java class files
and associated metadata
and resources (text, images and so on) into one file
to distribute application software
on the Java platform.
-- Wikipedia: JAR (file format)
... a WAR file (or Web application ARchive) is a JAR file
used to distribute a collection of
Java class files,
XML files, tag libraries,
static Web pages (HTML and related files)
and other resources that together constitute
a Web application.
-- Wikipedia: WAR file format (Sun)
Classpath is a parameter -
set either on the command-line,
or through an environment variable
that tells the Java Virtual Machine
or the Java compiler where to look for
-- Wikipedia: Classpath (Java)
An interface in the Java programming language
is an abstract type
that is used to specify an interface
(in the generic sense of the term) that
classes must implement.
Interfaces are declared using the
and may only contain method signature and constant declarations
(variable declarations that are declared to be both
static and final).
An interface may never contain method definitions.
-- Wikipedia: Interface (Java)
A Java package is a mechanism for organizing
similar to the modules of Modula.
Java packages can be stored in compressed files
called JAR files,
allowing classes to download faster as a group rather than one at a time.
Programmers also typically use packages to organize classes
belonging to the same category or providing similar functionality.
-- Wikipedia: Java package
This wiki page is maintained by Rich Morin
an independent consultant specializing in software design, development, and documentation.
Please feel free to email
comments, inquiries, suggestions, etc!