DEV Community

Discussion on: Ruby vs Elixir

Collapse
 
rhymes profile image
rhymes • Edited

I am a fan of Elixir even though I wrote zero lines of it beyond a hello world example.

Erlang is the first massively parallel language I came across with and it resonated a lot. I liked it so much that once I even started exploring ways to use it side by side with Python and succeeded (though without an actual practical use case). The Erlang movie is also the first time my head exploded in regard of concurrency.

Thanks to Joe Armstrong's book on Erlang my skills as a developer definitely improved, even though I never worked with Erlang professionaly. Thus, regardless of popular adoption, I am a secret fan of both Erlang and Elixir.

Ruby vs Elixir it's a bit of an unfair comparison as Elixir (though it has a kinship with Ruby) sits on top of an actual platform (OTP), with a VM (BEAM) which is profoundly different from Ruby's. It is designed around the concept that a process will crash and worst case scenario you'll just restart that process and the life of your distributed system "goes on". Let's not forget that WhatsApp runs on this platform :-D

OTP is a platform made to write fault tolerant parallel programs, it has simple primitives/functions allowing a developer to create a cluster of linked processes sharing no state (within the VM, not OS processes) with minimal footprint, organize them in trees of processes and have either monitoring processes attached to them or (this is where my head exploded at the time) even upgrade them with no downtime by hot swapping distributed code using versioning. It also comes prepackaged with a real time and distributed DB called Mnesia, which of course can be used via Elixir, though I'm not sure how popular that is.

When I think of OTP I think of concurrency made really well.

Ruby fits a much more popular concurrency model (run OS processes or run OS threads, fibers aside) and doesn't discourage people from creating a single process imperative program. I'm not sure if with Elixir is the same but spawning a process and linking it with another and send messages to it, is at the beginning of every Erlang tutorial :D

Elixir requires a developer to understand pattern matching, head/tail list manipulation, imperative and functional programming, a bit of declarative programming too, macros and other things.

Though many Rubysts are also Elixir programmers or have switched I think the amount of things to learn is a bit more.

Historically Elixir also suffered a bit because for the longest time the most popular cloud platforms were not supporting it natively.