The easiest way to get going with Clojure on a mac is with home brew:
brew install clojure
This gives you the clj command which launches a REPL where you can do the customary hello world:
Leiningen is a useful tool for creating Clojure projects; it is also available with home brew:
brew install leiningen
Creating a clojure project with leiningen is as easy as:
lein new oobook-lein
There is a clojure plugin and a leiningen plugin for Intellij that'll make your life much easier. Just go to plugins and search Clojure and Leiningen from the Settings -> Plugins -> Brouse Repositories. Once you have done this you can open your leiningen project in Intellij and you get an environment like this:
The integration with IntelliJ is really nice.
To open up a REPL to play with: Tools -> Start Clojure Console
To load the current clojure script into the REPL so you can use anything you've defined: Tools -> Clojure REPL -> Load files to REPL
To test your setup you can use the hello world example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns oobook-lein.core) | |
(defn hello-world [] | |
(println "Hello world")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'oobook-lein.core) | |
(hello-world) |
No comments:
Post a Comment