Hacker News new | ask | show | jobs
by jb1991 2540 days ago
I love hearing stories like yours. I wonder how Elixir would compare to Clojure, which I've used and liked for web development for many years. I hear nothing but good things about Elixir but I wonder if it would bring something new to the table for me in the "really liking it" category.
4 comments

I think you will find Elixir itself very similar to Clojure. They are both functional, dynamic languages with immutable data structures. They both use protocols/behaviors to achieve polymorphism in similar ways (e.g. functions working with collections (Clojure) and enumerations (Elixir)).

While there is a superficial syntactical difference I think the most important differentiation is the runtimes, the JVM versus the BEAM. JVM will outperform BEAM with regards to computations, while the BEAM has better support for true immutability and concurrency.

With regards to web development specifically the Elixir community seems to more or less have converged around a framework approach with Phoenix, while Clojure (too me) seems more geared towards a collection of libraries approach, รก la Node.js.

I don't have much experience with Clojure's tooling story, but the tools that come come bundled with Elixir, like Mix (build tool) and ExUnit (testing framework), are very good. Compared to the languages I have experience with (Python, Ruby, JS, Java, C#) Elixir provides the best developer ergonomics out of the box.

I haven't worked with Clojure, but one of my subscribers wrote me contrasting exactly that:

Wanted to thank you again for making these videos, I learned a ton and I'm really into Elixir now. If only there was a way to use it at work!

One of my favorite things about Elixir is Erlang/OTP. It's as if you're in Disneyland and everything's nice and colorful. But sometimes you go into a basement and you discover the entire thing is built on top of ancient Jedi ruins and these immortal, powerful forces lurk just beneath the surface, at your disposal.

Clojure is the opposite. It's all nice and fine as long as you're in Clojureland, but then you look behind the curtain and it's a huge pile of cards and matchsticks that hold everything together, and the glue is made of mutable state and classes.

And man, the tooling. I can't say this enough. It took me about 3 seconds to create a new project with mix new to get the unit tests and everything set up for the flatten challenge. I don't even know how to set up unit tests in Clojure, and I've been playing with it for 5 years.

So basically OTP == "ancient Jedi ruins" :D

IMO BEAM is a better VM than JVM despite the number of libraries.

It provides a more robust, performant and observable platform for Web development. (Technically JVM is faster batch operations but for Web, most Elixir apps win)

More importantly, it's a perfect fit for immutable functional languages. Everything is immutable and proper tail-recursion are provided. Clojure is great but it has several different ways to define state and type, and sometimes I found they're a little bit awkward. With BEAM process, there's no need for language to have constructs for state/reference/async handling, which could makes the language itself more simpler and more compact.

Relatively, JVM and Clojure ecosystem is much more mature and performant.

I would any day prefer Clojure and framework Pedestal.

https://github.com/pedestal/pedestal

More mature? Both Erlang and BEAM predate Java and JVM. The Erlang ecosystem is super mature and performant.