Appendix B. Setting Up Your ClojureScript Environment

Setting Up ClojureScript

ClojureScript is a dialect of Clojure that compiles to JavaScript. Clojure is a Lisp dialect that runs on the Java Virtual Machine. So, in order to use JavaScript, you need Java and Clojure.

Getting Java

You can test to see if Java is already installed on your computer by opening a command window (on Windows) or a terminal window (on Mac OS X or Linux) and typing java -version at the command line. If you get some output describing a version of Java, such as the following, you have Java installed:

java version "1.8.0_40"
    Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
    Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

If you get an error message, then you need to install Java. You may either use OpenJDK or Oracle’s Java Development Kit. Follow the download and installation instructons you find there.

Getting Clojure and ClojureScript

If you want to get started quickly with ClojureScript, I recommend that you follow the instructions at the aptly named ClojureScript Quick Start page. From that page, you can download a JAR file that has “the ClojureScript compiler and the bundled REPLs without an overly complicated command line interface.”

Creating a ClojureScript Project

Again, using the instructions at the Quick Start page, I created a project named sample-project. (I am sick and tired of “Hello, world!” so I did something slightly different.)

Here is the file structure ...

Get Etudes for ClojureScript 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.