Originally I posted this material on Syndicode blog. Updated.
I work in a Ruby on Rails agency, and we choose Ruby as our main programming language. But at the same time, we do use Elixir for a big part of our projects. How do we know when to use one of these programming languages? Here is the summary of the decision-making process. Elixir vs Ruby - where to use?
Recently I decided to make the primitive comparison of Elixir and Ruby.
|creator||José Valim||Yukihiro Matsumoto|
|purpose||concurrent language||developer happiness|
|most popular framework||Phoenix||Ruby on Rails|
Pros and cons of both Ruby and Elixir
|Battle-proven solution - based on Erlang VM (BEAM), the oldest virtual machines in the world, that remains broadly used. Elixir has a full access to Erlang functions.||Lack of developers - Elixir is still a fresh programming language, there may not be too much talent on the market with expertise in it|
|Performance - Elixir is a compiled language||Smaller ecosystem - Elixir is relatively young, there are fewer libraries around for it than for Ruby. This means that you might have to write features from scratch that you would get by simply importing a gem in Ruby|
|Elixir's documentation is very good. It covers everything and always helps to solve any problem you may have. It's also always available from the terminal.|
|OTP - Open-Telecom Platform is a set of tools for writing concurrent programs easy and fault-tolerant by providing a generic framework on top of which you can write your applications|
|Clean syntax - Ruby has a very clean syntax that makes code easier to read and to write.||Harder to maintain - Many Ruby libraries and tools use magic behind the scenes to keep the code concise. Also, Ruby doesn’t introduce any “good practices” out of the box|
|Ruby on Rails framework - it changed the way we write web applications, you can achieve so lot by writing so little code. It also made prototyping applications faster||Performance - Ruby was never meant to be one for performance. You may think that this only affects production speed, but it’s not|
|Ruby has a large ecosystem of tools and libraries for just about every use. Such as ORMs (Active Record, DatabMapper), Web Application Frameworks(Rails, Sinatra, Volt), Virtualization Orchestration(docker-api, drelict), CLI tools(Thor, Commando), GUI Frameworks(Shoes, FXRuby) and the list goes on.|
|Productivity - Ruby is a really expressive language. A couple of lines in Ruby can do the same job as whole chunks of code in other languages|
Elixir vs Rubby - where to use?
Elixir is your choice if you want to develop:
- concurrent connections
- high-traffic systems (like chat servers with multiple rooms)
- distributed systems
- systems that do stuff asynchronously
and other apps and services able to handle 100-1000000 simultaneous connections per computer.
Ruby is your choice if you want to develop:
- fast and secure web or mobile apps
- systems that nicely divide into smaller subsystems
and other interactive, with some kind of built-in functionality web apps and web services.
One interesting moment! Elixir is really awesome. But Functional programming paradigm is a different approach from object-oriented languages most programmers used to. So despite Elixir is as approachable as Ruby it is still a niche language. Elixir needs more time to become as spread as Ruby. Nowadays it's harder to find experienced and talented Elixir developers. But there are many newbies who were recently attracted by Elixir.
I wonder, what is your consideration when you choose between Ruby and Elixir?
Thank you in advance for your thoughts and comments!