Cursive vs Cider

I personally believe in #EmacsAllTheThings and have a great time with Cider, but am aware that emacs itself can be a problem to some people and that Cursive is madly popular (even getting shout-outs from Rich Hickey). What are some advantages of Cursive over Cider, speaking purely in terms of Clojure[script] development? What can be done that is harder in emacs?

Cursive shines for mixed Clojure/Java projects.

For pure Clojure[Script], the coolest feature is that autocomplete and some other things work without a REPL connected.

Apart from that, they seem pretty on par to me.

1 Like

Full disclosure, I develop Cursive.

I used to promote Cursive based on features, but from talking to people for quite a long time now I think the answer that matters most to most people to the question “What can be done that is harder in emacs?” is simply installing, setting it up and keeping it running with a minimum of fuss. A typical (invented) quote would be something like: I just want to get my work done, and I don’t want to have to spend time maintaining my editor to do so.

Plus, if a company adopting Clojure is a Java shop there’s a good chance they’ll already be running IntelliJ, so the way Cursive works will be totally familiar to them. In my experience Emacs has modes for nearly every language out there but they work in wildly different ways so you have to re-learn each one (obviously the basic text editing remains the same). JetBrains have done a fantastic job of making everything really consistent across different languages, so editing Java is much the same as JavaScript, Kotlin, Clojure etc, and other things like running processes, debugging etc also work in the same way. Similarly in Cursive, editing Clojure and ClojureScript (completion, navigation, refactoring, etc) is basically the same experience, which is less true of editors relying on a REPL since the REPLs work very differently. I believe this has been improving a lot in Emacs recently, but I don’t know the exact state of things there.

In terms of feature lists:

  • For pure Clojure projects, currently a tricked out Emacs with clj-refactor etc installed is considerably more powerful than Cursive. Cursive’s refactorings are still primitive by comparison.
  • For mixed Clojure/CLJS projects, Cursive has a more consistent experience across the two languages. I think Emacs currently has better support for CLJS REPLs though, although I’m about to fix that.
  • Cursive’s support for mixed-language projects wins hands down. Navigation/refactoring etc works cross-languages for all JVM languages, not just Java. Cursive is a Java/Kotlin/Clojure project and I have customers working on Scala/Clojure projects, and you can navigate back and forth, rename elements from one language from the other etc. Cursive also uses type inference in the editor to give great autocomplete for Java APIs from Clojure.
  • As didibus mentioned, everything in Cursive works without a REPL running, which is surprisingly nice.
  • Cursive can be annoying if your projects are macro-heavy, because it relies on static analysis of source. Workarounds for this are getting better these days but it’s still a problem.
  • The debuggers work in very different ways. Cursive’s is line based because it’s based on the JDI, which is occasionally annoying. That said, it also has a ton of features that CIDER’s doesn’t (stepping into Java and back, breaking on exceptions etc).
  • IntelliJ has a standard GUI interface, so it’s undoubtedly easier to learn than Emacs.
  • Cursive has great support for parinfer smart mode, which Emacs doesn’t yet.
  • In lots of other little details, one or the other is better depending on your preferences I think, but it’s mostly a wash I think.
21 Likes

Nice and thorough answer; thanks!

I honestly wanted to try Cursive - because I don’t believe in #EmacsAllTheThings but it ends up that only my terminal and web browser is keeping against…

So about my experience: maybe this was lack of my knowledge, but coming from Common Lisp world and being very REPL-oriented in development I was instantaneously frustrated.

  • REPL is nothing like in Emacs. Seems like raw text buffer, difficult to work with.
  • Keyboard shortcuts are painful, there’s no something like C-c C-c in emacs to compile current defun.
  • CIDER has good enough stepper-debugger, totally necessary with Clojure’s lack of meaningful error messages (cider-eval-defu-at-point with universal-argument in emacs (C-u C-c C-c). I’ve found nothing nearly as convenient in Cursive.

I’d love to use some well supported, OOTB environment different than Emacs. But I know none. Probably LightTable was the closest, I like it’s idea - but it’s de facto dead with deprecated dependencies (like old Electron).

Maybe you have any other ideas?

2 Likes

I’d like to add to @colinfleming’s answer that if you use the Webstorm/Ultimate IDE (paid) that comes with very good JavaScript support, you get full IDE support for it, which is very useful for mixed CLJS/JavaScript projects. You even get Google Closure support, as it understands goog.provide/goog.require, JSDoc etc. out of the box. In my project where we do CLJ/CLJS/JavaScript with some interop with Java and JS it’s very useful.

2 Likes

I haven’t found that to be the case, but then again I don’t normally write directly into the buffer, instead I tend to write in (comment ..) blocks and send sub-forms to the REPL.

They’re completely rebindable, and the one I normally use for this is “Send current top-level form to REPL”. It can be found by searching the Keybindings in InteliJ. I have it bound to CTRL-backtick as that’s much simpler than two key combinations.

However, the one feature Cursive has that Cider doesn’t (at least as of a few months ago), is the ability to send a top level form to a REPL ignoring the top level comment. As mentioned I put my REPL code in (comment (println ...)) format. Highlighting the println and “send top level form to REPL” results in sending the println since Cursive assumes there’s no reason to send the comment.

Cursive uses InteliJ’s debugger and adds quite a few useful features. You have to start the repl in debug mode (although that should be true for any JVM process), and from there you can use the common IDE keybindings of F8-F10 to step over, into, or out of functions. I don’t use the debugger much, as I rely mostly on the REPL for debugging, but every time I’ve needed it, the Cursive Debugger has done the job.

So maybe take a look at it again sometime. Maybe things have changed since you last looked at the IDE. Cursive absolutely fills that role of “it just works” Clojure editor.

1 Like

The “just works” is what I had hoped for when I brought in a Windows-operating student to join us on a Clojure project; unfortunately, two hours of attempting setup and he couldn’t get IntelliJ working; getting Lein, Git, and java versions all to work seemed prohibitively difficult

Doesn’t intelij come with git, and Cursive comes with lein? I’ve done this setup several times, and it’s Install JVM (may not even be required these days), install Intelij, install cursive plugin.

That being said, Windows is just crap for non-MS development. Python, Java, Ruby, PHP, Haskell, Erlang, I’ve worked on all of those in Windows and they’re all insanely painful to setup.

1 Like

I use Emacs on my Linux box, but at work I have Windows, so I fallback to Cursive. I tried to replicate the same environment I have at work at home, but I had issues with Cursive on Linux (I really don’t know why).

So my experience was: lots of pain to learn and configure Emacs (now I love it, but that’s another story) on Linux, really easy to get Cursive to work on Windows (for Emacs is the exact opposite, I can’t get it to work) but not working on Linux.

Cider’s approach is just to eval those sorts of things inline, instead of sending them over to the REPL. I do the comment form thing too (since seeing David Nolen doing it in a talk): I just stick my cursor right after the form I want to evaluate and run cider-eval-last-sexp (bound to C-x C-e by default).

It shows me the result of evaluating whatever it was inline, don’t have to switch buffers.

Like this:

cider-eval-last-sexp

1 Like

Oh, and it looks like there’s cider-insert-last-sexp-in-repl (default C-c M-p) to copy the form over to the REPL instead of evaluating it inline.

1 Like

Emacs was my first editor, and I spent 10 years in it, but having switched to Atom, and now having switched to Cursive, I’d say the biggest thematic difference is that I only use a handful of keyboard shortcuts now and instead rely heavily on the apropos command. I find a single keyboard chord followed by a quick search to be more ergonomic than the emacs way. Keyboard shortcuts do exist for the things I use often and can be customized easily, but the huge chunk of stuff that I only use once in a while is easier to get to in Cursive (and Atom).

I’ll also echo the “Just Works” aspect of Cursive along with the pleasure of high-quality static analysis. (My only real complaint is that Cursive still doesn’t understand javascript interop and creates lots of linter noise.)

2 Likes

Yeah, I know some people like that, but it really bugs me how Cider tries to hide my REPL history. It’s REPL driven development, not buffer driven development. Once that in-line text gets removed (for whatever reason) how do I get it back? And now I have the mental overhead of knowing what text is real, and what is overlaid by the IDE. Same issue with Lighttable, btw.

3 Likes

@Timothy_Baldridge
There is a pretty good explanation of how to fix this issue here:

2 Likes

also, hit , in the repl and it will pop up a browser of the entire repl history. But I agree I really like the cursive take on repl. You opened a ticket on github about this idea and hopefully it’s been useful to you since.

1 Like

Have you heard about http://spacemacs.org/ ? Like everyone I’ve also spend^Wwasted part of my life maitaining „the perfect .emacs”, but years ago I’ve switched to spacemacs which defaults are good enough so it suites me. Even more, I know people who drop their .emacs after like twenty years of building!

So in Spacemacs clojure is literally one line. Just add clojure layer and restart. That’s all.

Give Spacemacs a try! Don’t expect it to be exactly as you’d like, though. Although, some time ago I’ve discovered that it’s easier to change my expectations and habits rather than maintain all of my environments on my own.

PS: Just giving Cursive one more try!

1 Like

I can try it, let’s hope the proxy won’t complain too much with it :grinning:

That’s unfortunate. I can’t help with all of that, but if he stops by #cursive in Clojurians or the Cursive mailing list I can help him out with the IntelliJ part at least.

My getting started doc is woefully incomplete and out of date so it doesn’t mention this, but Cursive will actually use the JRE installed with IntelliJ by default if you don’t have any other set up - it’ll be called “IDE SDK”. It’s a 1.8 JRE with tools.jar (not a full JDK but most of what you need, and all you need for Clojure) which is usually plenty to get started with. Cursive will also download the lein uberjar automatically, so it will also work within Cursive with no setup. To use lein on the command line you’ll need to go through the Windows lein setup to get the script installed, and I believe that can be funky, yeah. But to be honest, I don’t drop out of Cursive to lein much, Cursive’s support is pretty complete.

Sadly I know nothing about installing git on Windows, so I can’t help there.