This post serves as an overview for the available IDEs for Clojure development at present. I won't go into incredible detail with all of the editors, but I hope to touch on every one. So whether you like Emacs, Vim, Eclipse, IntelliJ or Netbeans there should be something here for you who's thinking about Clojure.
First the disclaimer: If I miss anything in this post drop a comment and I'll update the post. I'm hoping to give people coming from other areas a stepping stone to Clojure Development. I spent many years in Visual Studio and there are definitely things I miss, like the fantastic IntelliSense, but with that said I'm an Emacs guy now and for me Emacs provides the highest level of productivity. Recognizing that not everyone feels the same way, lets look at the alternatives.
Vim-Clojure is a Clojure integration for Vim, which is developed by one of the Clojurians I respect the most, Meikel Brandmeyer. The fact alone that Meikels is pushing this is reason enough to try it out. He's also the guy behind Clojuresque, the Gradle alternative to Leiningen. Vim is a special kind of editor which is completely different from Emacs, so switching from one to the other is neither easy nor intuitive. However if you love Vims way of doing things, you'll be fine.
Rather than restating what has been said already, I'll refer you to this excellent blogpost, demonstrating an effective Vim-Clojure setup: Write Quit. Here's what it looks like in action:
Although Vim is powerful for editing (I'm told), its not heavy on integration with other systems like Emacs is, which is a big part of why I prefer Emacs - But nevertheless, it is a real alternative.
How did I miss this in my last post. Through the years France has produced two good things, Christophe Grand and Laurent Petit, the latter being both an excellent Clojurian and the author maintainer of Counter Clockwise (CC), the Clojure plugin for Eclipse. Being in Eclipse entirely changes the ball-game compared to Emacs/Vim. Its an editor with fast project navigation, it outlines all the functions of your program in a quickly browable tree, it integrates a REPL which works really well and is very responsive and it allows you to work in the same editor and in the same way as you would when working on traditional Java projects. This plugin is easy to install, except for one for one little hick-up. The first time I attempted to install it, I got some kind of server error in the first attempt, retried and it worked. Laurent put together this small video showing how its done: (no sound)
The only thing which isn't obvious, is that you don't have a Clojure Project option in the menu:
So just go with a regular project and then select Clojure in the Wizard.
Already Laurent has made some great additions to the feature list: Syntax coloring (rainbow parens like Vim), REPL interaction, code completion with Java doc, breakpoints directly in the Clojure code, namespace browser and more! If you make a new project, paste my ikeda code and click run, the animation will start rendering immediately and the code looks like this:
The reason - the main reason - why I wouldn't use this is because Laurent skipped a very important feature: Auto Indentation. Meaning that whenever you drop to a new line, you have to fix the indentation level yourself. That would wear me out in a minute. On the upside, I'm not seeing this as a feature which would take Laurent a long time to fix, so if you want it, motivate him! :)
Installing IntelliJ is an exercise in simplicity and nobody should have any trouble with it. If you're on Linux you might need to manually target the JDK:
export JDK_HOME=/usr/lib/jvm/java-6-sun....or whichever JDK you use
At first glance is a nice, responsive UI which isn't far from the Eclipse layout. Installing La Clojure is even simpler than CC, in that you go to File -> Settings -> Plugins. Then switch to the 'Available' tab, find La Clojure and right click it, choosing Download and Install. If you're opening IntelliJ for the first time, just click Plugin Manager from the front page (right side):
Once the process has completed, you'll be able to start a new Project Wizard, choosing: Create from scratch, name it and set up the directory structure and then just check the box 'Clojure' and you're ready to code! To add a Clojure file, right click the SRC node in the left window and choose New -> Clojure file, then paste my Ikeda code and you get this:
Click Run -> Run, choose a config and launch the animation. Like Counter Clockwise, La Clojure then downloads the version of Clojure which you have selected and sets up the entire directory structure, classpath and everything, so you can focus on coding.
The editing experience is similar to notepad, in that you have the syntax highlighting, but no completion like CC. The REPL seems strangely unresponsive compared to Emacs and CC, but that might be specific to my system. The feature list is as follows:
1. Customizable code highlighting
2. Code folding
3. Brace matching
4. Code formatting with customizable indentation
5. Structure view for definitions
6. Go-to definition feature (as go to symbol)
7. Code completion for definitions, special forms, Java instance methods and classes
8. Run configuration for Clojure scripts (both in REPL or as standalone script)
9. Debugger (also working in REPL)
10. Clojure classes compilation
11. Cross-language resolve and completion for Clojure namespaces, definitions and Java packages, classes and members
12. Find usages and rename refactoring for local definitions and symbols
13. Integration with REPL
All in all, pretty good.
The impressive Netbeans now also supports Clojure development by way of Enclojure. Enclojure has been around for a while and I actively being worked on. Of all the Visual IDEs I think this is by far the most feature rich alternative. Providing support for REPL both local and remote and project specific, persistent REPL history, Context aware completion and much much more:
And this is what it looks like:
I've tried 2 different versions and both times I get a Null Pointer Exception when creating a new project. I guess that why the sign on the door says Alpha. Sean Devlin from the Full Disclojure project had more success, check out this video to see his installation process: http://vimeo.com/channels/fulldisclojure#9220148
David Ungerer (Payroll Dude) adds the following:
I had the same null pointer exception about a week ago when creating a new project with Enclojure. Try opening the Enclojure preferences page and then selecting a Clojure version — it doesn’t seem to initialise this setting properly. Fixed it for me.
I also had to fix another null pointer exception before that, caused by having a Ruby version of NetBeans instead of a Java one — adding the Java module before installing Enclojure fixed that.
Eric Thorsen adds:
Since the lazy activation was introduced in Netbeans (I think in v6.7) the Java SE must be active in order for the Enclojure plugin to work. Apparently this depends on what flavor of the Netbeans was downloaded as to whether or not it is done by default. This can be done manually by going to the Installed Plugins tab under preferences, selecting the Java SE and clicking Activate.
There is a ticket to see if I can force this to happen automatically and at least provide a useful error message for this condition.
Once the Java SE is active, you should be all set.
These days installing Clojure-mode / SLIME is exceptionally easy. Start Emacs and hit M-x ielm. If you're new to emacs, M typically means ALT. In the new buffer, insert this code and hit enter:
(let ((buffer (url-retrieve-synchronously "http://tromey.com/elpa/package-install.el"))) (save-excursion (set-buffer buffer) (goto-char (point-min)) (re-search-forward "^$" nil 'move) (eval-region (point) (point-max)) (kill-buffer (current-buffer))))
Now you have ELPA installed, Emacs Package Manager. To view the packages hit M-x package-list-packages and scroll down until you find Clojure-Mode. Once the cursor is on that line hit i for install and then x for eXecute. After a couple of minutes, you should have everything installed and working perfectly. Test with M-x slime and if it doesn't work, restart Emacs and try again and/or read this: Link.
Like Vim, Emacs has code-highlighting and auto-indentation, but it doesn't have rainbow-parens, which I am thankful for. Like CC it has paredit which is not enabled by default - which I am also thankful for. It has enough integration options to let you do 95% of your work without ever leaving Emacs, meaning Git, SVN, Hg, Gist, SCPaste (pastebin), IRC, TODO/Task management and much much more. But it comes with a price-tag: It takes time to learn and the best way to get started, is hitting C-h t which starts the tutorial. Currently my Emacs looks like so:
Looks good, works wonders for your productivity and I've even heard rumors that in-code breakpoints are being worked into Clojure-Mode. (still very unofficial)
There's something for everybody and my impression is that pieces are quickly being put into place. If something was to lure me away from Emacs it would be Counter Clockwise which is sooo close to really good that I'll be keeping an eye on further development. All the IDEs except maybe Vim-Clojure will handle fetching Clojure and other dependencies for you (Emacs needs Lein/Clojuresque), so all you newcomers need to worry about is getting the plugin installed and you're good to go.
If you're intimated by Emacs but would like to try, just jump right it - I think you'll be surprised at how easy it is to get started these days. If you're not ready to jump on board yet, check back over the next few days I'm hoping commentators will help fill in the blanks in case I missed IDEs or important features.
For those of you who are ready to get going I recommend, as always, stopping by irc.freenode.net and connect with the friendly crowd on #clojure. You'll find Meikel (kotarak), Phil Hagelberg (technomancy), Rich Hickey (clojure), Laurent Petit (lpetit) and even Raynes there, so good times and constructive talks are guaranteed.