Blog
19.02.2019Cyprian Łakomy

Ruby vs Elixir Comparison. Which One Is Better for Your Software Project?

The debate over Ruby’s possible decline and the brand new era of Elixir seems to be alive and well in the dev community with threads like ‘Is Ruby on Rails dead?’ and ‘Will Elixir Phoenix destroy Ruby on Rails?’ on Quora and numerous similar topics on Reddit. But what if we are asking the wrong questions?

Ruby vs. Elixir is like comparing apples and oranges

You are a business owner, have an idea for a web app and are looking for the right software house to outsource for your project. You are a non-technical person, but stumbled upon terms like ‘web development’, ‘Ruby’, ‘Ruby on Rails’, ‘Elixir’ and ‘Phoenix’.

Yeah, we know it’s enough to make one confused about which technologies to use in building a product and finding a dev team with specific skills.

Or suppose you are a programmer who wonders if being a pro at Ruby is a sufficient skill for your current and future software development projects. You follow all these threads on Quora and forums and find yourself a bit unsure about the relevance of your coding skills. You are thinking about learning this new language more people are talking about: Elixir.

‘Comparing Ruby to Elixir is like comparing apples and oranges. This can be deceptive because Elixir's authors have been and still are major contributors to Ruby's ecosystem, and Ruby has definitely served as a syntactical inspiration for it. And a vast number of Ruby developers have followed suit, turning to Elixir - but in truth, its similarity to Ruby is only superficial’-

says developer Michał Buszkiewicz, who writes code in both Ruby and Elixir at Prograils.

Before we examine both languages’ specific properties, let’s lay out some historical background of Ruby and Elixir.

Ruby. A programmer’s best friend

Ruby was created in mid 1990s by Yukihiro Matsumoto, nicknamed Matz by the programming community.

Matz created Ruby with a programmer’s comfort and happiness in mind. The first thing you see on Ruby’s website is the caption „Ruby. A programmer’s best friend”.

The main concern of Matz was making coding in Ruby really enjoyable and productive, which led to the language being built to allow for rapid app development, rather than to push for high performance.

A breakthrough came in 2004, with the invention of the Ruby on Rails framework. Created by David Heinemeier Hansson while he was working on Basecamp, it was a real gamechanger in the way we write web applications in Ruby nowadays. It made the process even faster. The main advantage of achieving so much by writing so little code caused Ruby to gain traction on a scale never seen before.

Btw. Rails 6 is already on its way to being released. Read about the new Rails features like multiple databases support, Action Mailbox, Action Text and how your web application can benefit from them!

Elixir. A remedy for concurrency issues

In 2011, a long-time Rails developer José Valim, inspired by Ruby's flexible and elegant syntax, but still aware of its limitations in throughput and concurrency capabilities, created a language that's both similar and fundamentally different - named Elixir.

Elixir is a functional programming language, which makes it entirely different from the object-oriented Ruby. Despite this fundamental difference, more and more Ruby programmers are choosing Elixir as their next language, just like its creator and maintainer.

Elixir runs on Erlang Virtual Machine, which is a battle-proven solution for applications that scale fast.

The most popular web framework for Elixir is Phoenix, built by Chris McCord in 2014. Having drawn lots of inspiration from Rails, it was built with the goal of outperforming Ruby on Rails in mind.

This is why, having skills in both Ruby on Rails and Elixir/Phoenix, we decided to give you an in-depth, yet concise picture.

Ruby’s properties

Instead of a typical ‘pros and cons’ comparison, we decided to list the most vital properties of both languages. I asked Michał about how exactly Ruby and Elixir differ from each other. Let’s start with the former.

Readability through flexibility

Thanks to the language's powerful metaprogramming abilities, creating declarative domain-specific languages (DSL) feels as natural as it gets, and they are a big part of why a number of Ruby gems have become loved by developers. Good Ruby code rarely needs comments. It reads well enough to comment itself.

Productivity

Ruby's flexibility and the abundance of ready solutions to common problems have contributed to Ruby being an easy choice for startups, where time and other resources are particularly limited: according to specialists, a Ruby on Rails team needs 30-40% less time to build an application than teams using other technologies. And while question marks have been raised about its performance, it powers sites as huge as GitHub and Airbnb. Recommendations rarely get stronger than this.

Ruby on Rails

Ruby on Rails is a very mature framework with a developed ecosystem, where a lot of problems have well-established, de-facto standard solutions to specific problems. For instance, when you say "user authentication", you mean Devise, and even when you actually mean fancy authentication strategies such as SAML, you're still operating within what Devise can do with widely-known, well-tested addons.

At Prograils, while we highly value using good, re-usable solutions to problems, we're always ready to expand beyond them if necessary.

Elixir’s properties

Community

What you can obviously compare is the community, and while its size and the existence of ready solutions can't match Ruby yet, it has a very interesting dynamic and sees constant growth for a couple of years now.

Functional programming paradigm

Elixir is a functional language, which means that you focus on modelling your programs with functions, describing how one set of data is transformed into another. In contrast to other languages that also promote the functional programming paradigm, such as Scala, it has no object-oriented programming facilities whatsoever - one needs to completely forget about classes, inheritance and stateful objects. But fear not, it introduces modules, structs, protocols and a few other tools that make a developer's life easier. Functional programming often leads to better design choices and more focus on data flow, with all data represented as simple structures and all their transformations as functions.

Erlang Virtual Machine (BEAM)

The usage of BEAM and amazing concurrent programming features make Elixir a great option for anyone who wants to get their application to a next level. High-traffic services such as Discord have successfully resolved long-standing performance issues using Elixir, being able to serve several millions of concurrent users or significantly downscale their infrastructure after adopting Elixir. If this is what your application's future sounds like, definitely give Elixir a chance.

When should you use Ruby, and when to give Elixir a go

Now, having listed the most important features of both languages let’s highlight some real cases to which they can be specifically applied. What kind of services are fine with Ruby and which of them are worth considering Elixir?

Uses of Ruby

  • Prototypes – if you want to share your idea with the world and show your product’s potential users what it’s going to be like, Ruby is perfectly enough.

  • MVP (minimum viable product) – MVPs are created to enter the market quickly, with the minimum number of functionalities. There is a logic behind the fit between MVPs and Ruby: as new products rarely get traction right from the start, there is no large numbers of users and big scalability are usually expected. Read more on how Ruby and Rails can help your MVP.

  • Evolving app concepts - Ruby allows for quick modifications, which is extremely important when your project is only in the conceptualization phase. While requirements may change overnight, a well-designed Ruby on Rails application will let you implement changes easily.

Uses of Elixir

  • Apps with large numbers of concurrent connections – big numbers of simultaneous connections usually affect performance, but with Elixir/Phoenix they go hand in hand. If your application has chat channels, this means that there are concurrent connections that need to work simultaneously. And this is where Elixir/Phoenix is an option.

  • Apps with a heavy user count – to handle great numbers (i.e. thousands or hundreds of thousands) of users, as with Discord, Elixir won’t need countless extra servers.

  • Products with expected future growth – if your product is gaining huge numbers of new users in short time sprints, think about migrating it to Elixir.

Wrapping up

As you can see, there is no quick answer to the question „Is Elixir better than Ruby”? Both languages share similarities, but both differ from each other substantially.

Being over two decades old, Ruby has grown into a huge ecosystem with a worldwide community of contributors. The invention of the Rails framework along the way caused the abundance of solutions to specific problems to rise even higher – some features of your app can be just ‘a gem away’. The Elixir community is significantly smaller, but it’s mainly due to its relatively short lifespan, and the further growth is a matter of time.

Both Ruby and Elixir are known for their stability. Elixir runs on the mature and battle-proven Erlang VM, primarily designed for telecom and its highly concurrent services. Concurrency, scalability, fast growth and blooming user base of an app are possible indicators that Elixir will be a proper option. Learn more about the pros of Elixir.

Despite sharing similar syntax by Ruby and Elixir, the latter is a functional programming language which makes it completely different from object-oriented Ruby. It takes time for most developers to make the transition to functional programming. Fortunately, we have taken that time. We are ready.

Still wondering which language is better for your app idea? Shoot us an email, we will help you make this choice.

Again, a big "thank you" to Michał Buszkiewicz, for substantial contribution to this piece of writing.

Still want more?

Read our new Elixir/Phoenix vs Ruby on Rails comparison from the business outlook.

Photo by Louis Reed on Unsplash

Recommended reads:

Check our latest product - it's based on our experience of managing over 50-people strong company. The tool we're missing as a small company and not an enterprise.

humadroid.io is an employee and performance management software. It's an unique tool allowing everyone to be in the loop - by having up to date info about co-workers, time-off, benefits, assets, helping with one-on-ones, being a go-to place for company-wide announcements.

Check out humadroid.io
Top

Contact us

* Required fields

The controller of your personal data provided via this contact form is Prograils sp. z o.o., with a registered seat at Sczanieckiej 9A/10, 60-215 Poznań. Your personal data will be processed in order to respond to your inquiries and for our marketing purposes (e.g. when you ask us for our post-development, maintenance or ad hoc engagements for your app). You have the rights to: access your personal data, rectify or erase your personal data, restrict the processing of your personal data, data portability and to object to the processing of your personal data. Learn more.

Notice

We do not track you online. We use only session cookies and anonymous identifiers for the purposes specified in the cookie policy. No third-party trackers.

I understand
Elo Mordo!Elo Mordo!