Five reasons to learn Clojure and Emacs together

December 27, 2012 § 13 Comments

There’s often debate about whether newcomers should try to learn both Clojure and Emacs at the same time. My take on it is that yes they should and here’s five reasons why.

1) Liberation

Smart IDEs ares like powerful drugs. They treat the sick and the dying wonderfully well but tend to concentrate on the symptoms more than the problem, that of bloated code. They are great for refactoring around masses of static types, but you do so inside of a walled garden in that the features you want are built into the IDE itself, and therefore you have to rely mostly on the IDE developers to make things better. The modern powerhouse IDEs are complected.

Emacs at heart is a basic text editor, one that has been around for decades with extensibility at it’s core. Because of this, and the fact it’s open source, the plugins for Emacs are essentially limitless in what they can do. There are vast amounts of major and minor modes and colour themes. Org mode awaits you.

It’s this ability to tailor Emacs so much that makes it feel liberating; you can do what you want with it. And if you really don’t enjoy a spot of configuration-masochism then they are many ‘starter kits’ on the web that will quickly get you going, see the ‘Emacs Starter Kit’ for starting out with Clojure. You could postpone engaging with Paredit mode if you wish, and make use of Cua mode to bring the sanity back to copy and pasting. The feeling of liberation can always be throttled.

2) Change

Moving from a statically typed language to Clojure is not easy. With this in mind are we really making things that much easier by encouraging devs to stick things out in a familiar IDE? Without a pertinent and dramatic sense of change are we not just making things harder? Why try to disguise the fact that Clojure is a different development world away from Java. You can’t refactor or navigate around in the same way and the debugging just isn’t as good. Developing in a sophisticated IDE without 80% of the IDEs usefulness would likely be incredibly frustrating and a turnoff. You’d be dressed up for the wrong gig.

Change also begets change. Moving to Clojure is a chance to review a lot of things; the VCS used, testing tools, approach to CI, artefact management, anything could be up for grabs. Better to make a clean break from the past.

3) Support

Following on from 2 there is the issue of support. You could be ambivalent about devs on your team using Clojure with their favourite Java IDE but then you must consider what the support cost will be. They may stumble across some half hearted wiki page about getting a certain Clojure plugin working but then would it work with Lein 2 and not just Lein 1? Is it using the deprecated Swank-Clojure or NRepl? The Clojure landscape is still shifting, newbies should probably be using the best lifeboats.

4) Simple and Easy

Like with Clojure learning Emacs from scratch isn’t excessively easy but then in the long run it’s simpler. Why would we suggest newbies to stick with their current IDEs when there’s a danger that they might not move on afterwards? Clojure and Emacs are a package of simplicity, they go well together.

And we know that simplicity is not always for free. There has to be some learning-pain before you can reap the rewards. If a developer is truly unwilling to switch to a lighter weight, more extensible dev environment then they may also be equally unwilling to make the paradigm shift to functional programming.

Of course the flip side to this is that it’s possible a developer may go to lengths to make coding even more of a pleasurable experience in the smart IDE landscape. If so, then hats off to them.

5) Mass Adoption

Trying to spread Clojure whilst recommending an IDE change sounds very counterintuitive, but then is Clojure itself ripe for mass adoption across the industry? Is this the end goal? These questions are beyond the scope of this post, but suffice to say that I’m not sure it would be a good thing if all people at the large institutions I’ve worked at started coding everything in Clojure. Emacs certainly adds to the learning divide, and makes it more explicit.

Please Vim warriors take note that these arguments could just as easily pertain to Vim.

  • Donald Parish

    I did try Emacs when starting Clojure, but have been very pleased with the progress of the CounterClockwise plug-in for Eclipse. Am also starting to drink the Vim Kool-Aid. The Catnip editor is also very good for casual editing. It includes matching parens ala Paredit, always a good thing.

  • Jon Pither

    Hi Donald. Haven’t used Catnip but I’ve seen it used – it does look nice, also for ClojureScript. Given you’ve used CounterClockwise I’d be interested to hear your thoughts on some of my post – i.e. that it would better for others to go straight to emacs/vim.

  • Phil

    One reason not to learn Clojure and Emacs together: it’s really, really hard, and if conversations from the Clojure channel on IRC are any indication you’ll probably get disoriented, frustrated, and give up.

  • Jon Pither

    Hi Phil – I hope people wouldn’t give up – but yeah. Only one reason needed against Emacs + Clojure at once – it’s hard (ish).

  • Katox

    I’m used to working without any IDE (vim + shell) still I had hard time with clojure (with starter kit) and emacs together. It wasn’t because of the editor itself or paredit (which I like a lot) but mostly because of buffer and window management.

    I can fire up repl, connect to a project and stare in awe. What buffer will get replaced by this form evaluation? Buffer where I’d opened funtion docs? Repl itself? The main code buffer even? No idea it seems just random at times (plus I don’t remember the key bindings to fix the resulting mess quickly).

    And the output – where did it go? Mini buffer? Repl output? Messages? Somewhere else? And what part is where?

    Plus a few fav peeves like hitting triple Esc to cancel the last action and see all the carefully positioned open buffer close in an instant :)

    Still I hope to get a clue with buffer management :). This or learning till light table does something useful and then switching :)

  • devrim baris acar

    IMHO, I have to disagree. I am not good at memorizing keyboard shortcuts ( i was not good at Street fighter II too :) ). Emacs seems to be a lot of investment for me to get the basics of clojure, so I gave up and have been trying intellij, so far much better.

    If I get the feel of clojure, I will switchto /try/evaluate once more Emacs, till then I only want to focus on one hard thing at one time, and clojure seems more logical to focus my precious time.

  • Konrad

    @Katox: I had the same problem with closing the mess. But recently I noticed that many buffers can be closed just by “q”. So for example you get stack trace. Than you go to buffer of stack trace with c-x o. And then q. It will be closed or buffer state will return to previous. No one is saying about “q”, maybe because it’s a standard in emacs world, and people forgot to write about it :).

    BTW: I recommend setting keyboard shortcuts for switching between buffers (e.g. Meta-left etc.).

  • Jon Pither

    @Konrad and @Katox. I used to have switch buffer bound to meta-left etc, but I found this messes up Paredit and org mode should you use it, so I’ve reverted to using C-x 0.

    Also checkout winner mode, if you lose your buffers setup this can get you back to how you were.

  • Tim, Steve & Peter Bates

    What are you banging on about. Any way have a fantastic new year and see you in 2013

  • Pingback: Monadic IO with ScalaZ | My programming escapades()

  • Denis Labaye


    whether you are learning Clojure or not, you must learn Emacs.

    I learned Emacs while learning Common Lisp, just because I was too tired of matching the closing parenthesis ;-)

    Then I discovered:
    * the keyboard mapping that I was investing into where also applicable in Bash, and in tmux, and …
    * org-mode: which is my primary way of organizing myself since then (and the Emacs gateway drug for convincing other users)
    * working with git (maggit) was a awesome
    * auto-completion like in other IDE (but better)
    * Emacs usable on the command line, so that you can edit with your favorite “IDE” even on remote headless servers. And remote pair programming (tmux, screen) is as robust as your regular SSH session.
    * And the keyboard macros, everything is programmable, the minibuffer, the package manager, the huge number of languages and file formats supported, and ….

  • Josh T

    @Katox: I hear ya. I’d love to find a tutorial or blog post about buffer/window/process management written for those who have a bit of experience with Emacs (a couple weeks of working with it full time, or a few months of free time playing, etc.) but still see themselves as “learning” it. The [Mastering Emacs][] blog stands out for me by consistently writing for that audience but —to my knowledge— he hasn’t written anything that addresses your bunch of questions yet. I’ve also heard of Winner Mode, but haven’t gotten around to looking at it.

    @Jon Pither: I’m loving Emacs, but newcomers to Clojure shouldn’t let Emacs get in the way of exploring Clojure. I believe that learning Emacs well carries many benefits (reading your post made me aware of even more of them!) but I try to be careful to keep it from sounding like a prerequisite for playing with Clojure.

    [Mastering Emacs]:

  • valentin

    Separation of concerns also applies in learning : break the difficulty into independent obstacles and overcome them one after the other, in isolation.

    In spite of all the merits of Emacs, the fact that opinion leaders of the Clojure community take it for granted is a hinderance to Clojure’s adoption. I always feel embarrassed when I suggest my friends to try Clojure(Script), and then tell them that they Emacs is the only editor with complete Clojure tooling.

    As for editing, I personally think Laurent Petit made choices for Counterclockwise that are both simpler, more productive and more intuitive than what I’ve found for Emacs so far (and I’ve been trying a lot).

What’s this?

You are currently reading Five reasons to learn Clojure and Emacs together at Pithering About.