What is Clojure?
Clojure is a modern programming language. Depending on your skill level, you can create any type of software with Clojure. This includes games, web apps, mobile apps, and desktop applications.
The first step in programming Clojure is to install it and other things needed for creating Clojure programs.
Continue reading “Hello Clojure”
Most of the Clojure tutorials and Clojure examples on this site require at the minimum Clojure to be installed. Usually, you want Leiningen installed too.
Seriously, do it once and ignore it for the rest of your learning experience. Here are the steps for getting Lein and Clojure up and running.
Continue reading “Installing Clojure with Lein”
Sometimes you need to configure
lein to use a custom JDK. On Linux, set the environment variable
JAVA_CMD to point to the
java executable you want
lein to use.
For example, you might add the following lines to your
#used by LEIN
Once you update your bash profile, you can start using your configuration by using the following command.
NOTE: All the code in this tutorial can be quickly tested at the REPL using the command
lein repl to start a REPL to test with.
One of the first things you learn when learning clojure is
println . For example,
That’s probably the first Clojure program you ever wrote. Maybe you wrote this variation.
print are the first ways learned of displaying output in Clojure, most Clojure developers continue using them when debugging code. Nothing wrong with that. But sometimes it is better to use a more specialized tool.
In steps the
pr commands. These two commands are tailored for printing objects. At first glance, they appear to work the same as
println . However, they actually show more information in some instances.
println , the
\n in the following code quietly gets replaced by the action of a new line being printed.
prn are used, the two characters
n are displayed instead of an actual new line. This is very handy when hidden characters are fowling up your layout, or needed to be visible when debugging code.
Final note: The only difference between
prn , is that
prn prints a new line after the objects it is printing out.