sashaafm

sashaafm

Opinions on Elixir vs. Clojure

What’s your opinion on Elixir vs. Clojure?

Most Liked Responses

shanekilkelly

shanekilkelly

[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
Post #2
rvirding

rvirding

Creator of Erlang

Not quite as ports make the outside world look like a “process”. You communicate with it using messages as you would with any other erlang/elixir process. You are even linked to it. In this sense interacting with the outside world through ports is very clean, or at least very erlangy/elixiry.

Robert

gregvaughn

gregvaughn

I was paid to work in Clojure for about 9 months, and now I’ve been paid to work in Elixir for 10 months. Here’s a few points to consider.

  • Syntax: Do you love to be hands on with the lisp AST? I tried really hard to like it, but I found it hard to skim unfamiliar Clojure code and get a high-level gist of what’s going on. I really had to read it carefully statement by statement to understand it because it lacks higher level syntactic signposts. Elixir offers those signposts, plus a macro system that is just as powerful. The only tradeoff is that Elixir macros are not as “natural” because it’s not fully homoiconic. I’m fine with that. Others aren’t.

  • Built in Libraries: I found Clojure to have a very broad standard library. There are many specialized higher-order-functions for what seem like rare situations to me. If you know the library well, you can probably use one of these to create all sorts of elegant one liners – and make it harder for the maintenance programmer to reason about. Elixir, in contrast, says “no” to a lot of proposals to add things to the standard library especially when they can be expressed in 2 or 3 lines of existing functions.

  • The VM/ecosystem: JVM has a larger set of libraries. It also lacks the memory isolation to do proper supervision/fault-tolerance the BEAM can do. Interacting with Java libraries from Clojure was more awkward because of the imperative/functional mismatch than interacting with Erlang libraries from Elixir, which are both functional/immutable.

Where Next?

Popular in Discussions Top

praveenperera
How We Replaced React with Phoenix By: Thought Bot
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
AstonJ
If a newbie asked you about Phoenix Contexts, how would you explain the basics to them? Feel free to be as concise or in-depth as you li...
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement