Clojure IDEs - The Grand Tour

2010-03-16 13:08:10

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.



Preface

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

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.


Counter Clockwise: Eclipse

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)

httpv://www.youtube.com/watch?v=1T0ZjBMIQS8

The only thing which isn't obvious, is that you don't have a Clojure Project option in the menu:

Eclipse NewSo 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:

Eclipse Ikeda

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! :)

UPDATE: Somebody certainly motivated Laurent as he has now implemented both auto-indentation and paredit (80% of the commands) and even released a little cheatsheet to get you started!


La Clojure: IntelliJ

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):

Plugin Manager

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:

IntelliJ Ikeda

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.


Enclojure: Netbeans

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:

Enclojure

There's just one problem: I cant install it!

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

UPDATE (17/03/2010)

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.

UPDATE (19/03/2010)

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.
Eric


Emacs

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:

Emacs IDE

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)


Conclusion

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.

Arthur Ulfeldt
2010-03-16 20:24:01
I have been "waiting" for one of the heavy-ides (enclojure, counterclockwise, la clojure) to have all the features I need and using emacs+leiningen in the meantime. lein+emacs seems to be improving faster than the others so I'm not sure when they will catch up. I think having more traditionally java focused IDEs for clojure is really critical for getting people to use the language, especially at work.
Chas Emerick
2010-03-16 20:25:32
Nice roundup, Lau.  I've been using enclojure for a *long* time (a year? 18 months? Sheesh.)  One big selling point for enclojure is its great support for remote repls -- it offers a repl-server library (~12k jar) that you can add to your apps and thereby load code remotely, etc.  I think there's something similar for swank; not sure about the other environments.

Anyway, if you continue to have an install issue with enclojure, swing by #enclojure on freenode or the list (http://groups.google.com/group/enclojure).
Phil
2010-03-16 20:27:32
I just feel like I should mention that package.el is about to get integrated into the next version of Emacs, so pasting that unsightly blob of elisp in ielm should be unnecessary in the future.
Payroll Dude
2010-03-16 20:55:39
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.
Vagif Verdi
2010-03-16 22:24:04
There are 2 killer features of emacs+slime that i cannot live without that are missing in IDE clojure plugins.

1. Connect to remote Repl. Enclojure has it, eclipse plugin not.
2. Ability to develop on remote machine. I run emacs in terminal screen session.

With netbeans/eclipse i would have to run the development web application locally and develop locally and then deploy to remote machine. This develop-deploy cycle is what i do not like and would like to avoid.
Hubert
2010-03-16 22:38:57
I've tried all except Eclipse based.

Since I rediscovered emacs, it's been about 10 years of vim here, I'm all hooked.

Not only Clojure integration feels like it was really well though, whole thing is lisp based, it offers so much more. Recent discovery of org-mode made me totally switch.

I still use IDEA for Java development, but my search for Clojure IDE is over: Emacs wins.
Lau
2010-03-16 22:40:53
Wow thats great to hear Hubert, I mean this Vim vs Emacs thing has been going on for ages and now its finally settled, Emacs wins, hooray! :)
morphir
2010-03-17 00:31:22
the emacs experience is horrible. The fact that somebody recommends this key-combo piece of junk is beyond belief! Emacs is hindering lisp adoption. Emacs shall die by my sword! http://trac.sacrideo.us/wg/wiki/ReplBehavior
Arnab
2010-03-17 00:36:05
Have you used TextMate? I'm a heavy TM-user and there seems  to be a bundle for Clojure: http://github.com/nullstyle/clojure-tmbundle

Would be great to get some feedback on this (from you or readers of this post)
Tom
2010-03-17 02:55:22
/shameless plug/

None of these except Emacs have any refactoring support.

I think emacs really wins because of paredit, clojure-test-mode and the fact that the majority of the clojure community use it (there was a survey that put emacs in the lead by ~20% iirc)
Laurent Petit
2010-03-17 09:58:47
Hello,

First of all, thank you Lau for the kind words. I think that all of us IDEs contributors really appreciate it !

Now, concerning counterclockwise, I would like to add 2 things: 

Even if it feels like I'm the only one to write it, it's not the case: there are many contributors. Without them, ccw would not have the code outline, the preferences page for syntax coloring, etc.

Concerning auto-indentation: it's already working on my laptop, I'm polishing it those days, it'll come with the next release, hurray ! :-)
Michael Kohl
2010-03-17 13:58:13
@Arnab: The Clojure bundle for TextMate is quite ok, definitely enough to just start playing around with the language. 

@Lau: Preface, last sentence: s/not every/not everyone/
Lau
2010-03-17 14:34:20
Thanks Michael, fixed.
Jeff
2010-03-18 01:46:48
I feel I must write that installing slime and clojure mode in Aquamacs was enough to make me almost give up on Clojure. I figure anyone who would be using an editor I was using 20 years ago to read USENET posts had to out of the minds. And the installation using ELPA failed dozens of times with me trying dozens of different thing to get it to work. Finally I was able to get it to work by hours of searching on the net through groups and outdated blog posts finding that I had to create a .swank_clojure directory and install a swank-clojure.jar there. 

My advice, EMACs was state of the art 20 years ago on Sun 2/120's running BSD 4.2. It is old and ready for the dust bin. And also happens to be the best Clojure editor for now. This alone will keep Clojure on the fringe.

La Clojure is not ready for prime time as the REPL is horrible. Not sure there is any activity on it.

Sounds like CC or Enclojure is the way to go. I dislike Eclipse so I'll give netbeans a shot.

But really, a 20+ year old editor I was using to read email, usenet, and edit C on my Sun 2/50 68010 workstation in the early 90's is the best we can do? Apparently for now. Yes.
Michał Marczyk
2010-03-18 02:10:14
Oh, that's a nice roundup! The quality and diversity of available options (and with 1.1 being the latest release of the language, 1.0 still fresh in memory) is really quite amazing.

Taking the opportunity to plug a piece of my own Emacs config, Emacs can be configured to provide a bit of a "local" rainbow parens effect:

http://stackoverflow.com/questions/2413047/how-do-i-get-rainbow-parentheses-in-emacs

I'm sure one could do VimClojure-like highlighting, but I happen to find this "local" solution very convenient.

Thanks for the dark-bliss source (from the other post), by the way -- that's the first time I've considered using another theme sometimes since I first found Zenburn. Would you happen to know who the author is? (I'm not sure if you meant to imply etate's written it.)
Lau
2010-03-18 08:39:58
Hi Michal,

Thanks for stopping by. Dark-bliss is authored by etate.
Lau
2010-03-18 08:44:10
Jeff,

I can certainly understand that you're sitting with a certain amount of frustration after the failed attempts at installing in AquaMacs - If you had only started the process by reading my "Clojure 101- Installing Emacs & Slime" you would have been all set up in 10 minutes. Anyway, the age of Emacs is a testimony to its power and ability to adapt. I am not using Emacs with any feeling of want for anything else, I use it because it fantastic for maintaining high levels of productivity. CounterClockwise and Netbeans are however serious alternatives if you prefer that kind of editor. La Clojure needs a little work, but its not far from being really good either - My main reservations were the ugly highlighting and the unresponsiveness of the REPL, but the editor as a whole is great.
Phil
2010-03-18 17:18:03
Jeff: Aquamacs is a *fork* of GNU Emacs. Having problems with Aquamacs doesn't indicate problems with regular Emacs. Since Aquamacs isn't portable, it's impossible for maintainers to test code on it, so it's no surprise that it doesn't work as well.
Eric Thorsen
2010-03-19 16:51:27
Thanks Lau for doing this!  It's tough to keep up with all that is going on in the tools area particularly when I am mainly focused on one :)

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.
Eric
polypus
2010-03-20 08:41:21
Jeff,

Aquamacs is not the way to go. Get cocoa emacs 23 here: http://emacsformacosx.com/ and then follow Lau's instructions. It's actually pretty easy.

_c
Ben Atkin
2010-03-21 07:08:17
Thanks for posting! I used your post while trying to get a good Clojure IDE setup while I was attending the Boulder Lisp User Group.

I wanted to try Enclojure with Netbeans, but only if I could get it to build so I could make changes. I didn't manage to get it to build. I just couldn't get Apache Ivy to install the prerequisites. It failed to install jetty. I'm not sure why jetty was required. I gave up and started looking at other options.

I've been using vim and calling myself a vimmer, but I decided to get Emacs and SLIME running. I really liked it. In fact, I enjoyed using it so much that I may switch back to Emacs for everything. (I've been using VIM for over a year now, but before that, I used Emacs for a few months.)

I used SLIME with Incanter. It was pretty cool. I like how the JVM that Clojure is running in is separate from the JVM being used by other parts of the editor. It worked well with Incanter's charts library. I blogged about my new setup here:

http://benatkin.com/weblog/2010/03/20/incanter-and-aquamacs-on-mac-os-x-with-leiningen-and-aquamacs-emacs-starter-kit/
Ben Atkin
2010-03-21 07:13:59
Also, I'm sorry that Jeff had such a horrible experience with Aquamacs. I like it, so far. I've seen progress from a previous version of it, and that's a good sign. In certain cases, I don't mind forks, and Aquamacs is one such case. I agree with Phil that people shouldn't base their opinions of official versions on the experiences they have with forks.

I'm happy to try and help you get SLIME working with Aquamacs if you so desire, Jeff. Send an email to ben@.com.
Gabor
2010-03-24 13:30:24
To us, puny Windows users, there is Clojure Box (http://clojure.bighugh.com) which is great for the Emacs newbies... the Eclipse plugin looks also very promising though.
metacagoule
2010-04-16 14:55:44
Instead of extending IDE's to use clojure.. one should make an IDE in clojure, emacs' grandson; just a thought.

** already drooling
Lau
2010-04-16 17:43:52
@meta: I have to admit that the thought of another Swing UI doesn't exactly make me drool :)

I recommend using Emacs, the benefits are extreme in terms of efficiency.
metacagoule
2010-04-17 01:19:27
Yeah, we need something in the lines of Subtext ( if you never saw it : http://www.subtextual.org/index.html ). I really think it would be a nice evolution for emacs to evolve along those ideas, repl revisited.

Bye