Opinions on Elixir vs. Clojure

[warning, a bit ranty]

Let’s put it this way:

I’ve been doing Clojure as a hobbiest for about four years now, and learning Elixir at a beginner level right now, and I already prefer Elixir over Clojure.

Clojure upsides:

  • it’s a modern lisp
  • the JVM platform is fast
  • the language design is generally well thought out

Clojure downsides:

  • the “java layer” pokes through far too much, and unlike Elixir/Erlang the underlying Java idioms do not interact well with the functional-programming paradigm of clojure.
  • documentation is pretty bad, and remains bad after years of badness (Elixir docs, even for community libs, are much better)
  • as a side-effect of poor documentation: there’s often not a coherent story on “how to achieve $FOO” with Clojure. My most recent example was trying to figure out how to build pervasively-non-blocking and highly parallel http services in Clojure. I’m sure it can be done, but it’s very hard to figure out what will work.
  • the build tool (leiningen) kinda sucks
  • JVM startup time is torturous, by comparison iex/elixir starts almost instantly

And perhaps the biggest problem I’ve found: the core Clojure community is made up mostly of “90’s Java Guys” who wanted to work with a more sane language on the JVM. The rest of the community is FP enthusiasts who aren’t particularly invested in the JVM. In my opinion the first group end up dominating the culture too much. As a result of this, making anything bigger than a toy example app in Clojure involves getting your hands dirty with awful Java libraries. One minute you’re happily coding along in Functional Land, the next you’re digging around in the OOP, mutable-state muck of Java Land again. (see: https://twitter.com/shanekilkelly/status/703297846401957889).

This is a decent value proposition if you’re already financially/professionally/emotionally invested in Java, but for the rest of us it’s a painful experience best avoided.

Elixir, by comparison, doesn’t seem to suffer from the same impedance-mismatch with it’s host platform, which makes me a lot happier instantaneously. That and the fact Elixir has a coherent narrative when it comes to scalable computing, it’s looking like I’ll be investing more of my time in Elixir than Clojure.

EDIT: I decided this post was a bit too negative, so I’ll expand on some of the positive aspects of Elixir, from my point of view.

Elixir upsides:

  • very good documentation and on-boarding material (especially considering the size of the community)
  • a better approach to namespacing/modules (clojure chucks a huge number of functions into the global namespace, while Elixir prefers to put ‘default’ functions in modules like Enum)
  • a coherent vision for massively parallel and distributed computing and the multi-core future
  • the Elixir devs and community seem to really care about code ergonomics
  • the BEAM is an awesome piece of technology
  • mix, and the general ecosystem of tools around Elixir, seem very nice and pleasant to work with
18 Likes