Programmer. Hiker. Cook. Always looking for interesting problems to solve.
Setting up IntelliJ for Clojure
03 Jun 2013 |
I have been interviewing for a summer internship and my interviewers and I talked about Clojure. I am now intrigued by functional programming.
- Parentheses? Not so scary considering they “replace” Java’s (the only language I currently know) curly brackets and multiple commas. Code is surprisingly easier to read.
- Immutable data? A chance to stop wasting time thinking of when and how object’s state is modified.
- Being based on JVM allows to use Java’s libraries
Whether I get this internship or not, I decided to learn Clojure First step: setting up IntelliJ.
- Download and install La Clojure plugin.
Open File/Settings/Plugins from a menu, than click on Browse repositories… button at the bottom of the Settings window. Type in Clojure in the search window and select La Clojure from plugins list. Right click on the item and select Download and Install command. Restart IntelliJ.
- Add Clojure Facet to project modules.
Select File/Project structure from a menu, then navigate to your module in Modules tab, click on a + sign and finally select Clojure.
- To start Clojure REPL for your project select Tools/Start Clojure Console from a menu.
The REPL will set a classpath for all of your libraries and sources referenced in a current module.
- To load a current Clojure file to REPL by a load-file function, select Tools/Clojure REPL/Load file to REPL.
It’s that simple.
P.S. It’s good to add leiningen to IntelliJ (easier to get a
project up and running, build, run tests) but for now I am skipping this step.