6 Reasons Why Elixir Is Better Than Ruby
By: Foxbox Digital
Tags: Programming, Ruby, Elixir, Software Engineering, DevOps

1. Development Velocity

Let’s be honest — we’re excited about Elixir’s effortless handling of concurrency, but it’s not the main reason we stick with it. Elixir is a highly productive language. Here are some reasons for that claim:

Simplified development setup — Utilizing the BEAM virtual machine, one can expect to have a consistent development experience on almost any machine — even Windows. While this can also be true for Ruby, as a project progresses, a typical web application in Ruby accumulates more dependencies that make it increasingly difficult to get it up and running, while an Elixir web application would remain relatively easy to set up.

Predictable codebase — Elixir enforces true lexical scoping and encourages explicit codes. What this means at the code level is Elixir makes data transformations, code organizations, and application interfaces much more predictable and easier to reason with — thus saving a lot of development time.

Lightweight and fast testing — This is probably the most undermentioned yet powerful benefits of using Elixir. Elixir provides developers access to super-fast, concurrent testing with relatively minimal impact on hardware performance. Ruby testing, on the other hand, can be painfully slow and hardware-intensive — to the point it could bog down the whole system for those with underperforming machines. Elixir completely takes away the headache by making tests faster.

Useful built-in features — We‘ ha’ve used Elixir to build a quick MVP project to building large-scale projects. In both scenarios, Elixir provides powerful built-in features to satisfy the requirements for a typical modern web application, such as caching, background processing, and process monitoring. On a platform such as Ruby on Rails, these solutions usually come with tightly coupled dependencies on services, such as Redis, Resque, and Foreman.

I’ll admit, at first, I was extremely frustrated with Elixir.

I struggled with pattern matching, which was touted as this revolutionary new concept. After getting used to it and all of the other advantages of Elixir, though, I’ve found myself coding with less effort and frustration to achieve the same exact output as Ruby. There are two reasons for this.

It’s a functional language

Functional languages, as opposed to object-oriented languages like Ruby, are beautiful and simplify programming. I greatly favor functional languages for several reasons:

They lead to coding faster and more predictably

No state to keep track of. States make it extremely difficult to track down problems. There are no reference errors. Everything is a pure function, which is wonderful.

It has pattern matching

One of the biggest advantages and differentiators of Elixir is pattern matching. Pattern matching comes from its Erlang roots and is one of those things you wish was also incorporated into other languages.

One of our very talented engineers put together a code-sample comparison between Elixir and Ruby using a simple ranking example.

In that example, pattern matching makes the code more elegant, expressive, and easier to read. It may seem like a small thing, but I find myself using pattern matching any chance I get.