Over the past ten years, more and more companies, among which are Pinterest, Moz, and Bleacher Report, have switched to Elixir. Not to mention products like Discord and WhatsApp that were built with Elixir right from the start.
What's the reason?
Simply put, using Elixir for development results in services capable of processing much bigger traffic. You'll get a platform that can quickly scale and grow without losing reliability while increasing overall performance. In business terms, it means more users, more sales, and a higher ROI.
We at Mind Studios have repeatedly found Elixir beneficial for projects where real-time communication or concurrent data collection takes place. Our experience in using Elixir for web apps, and a secure messaging app in particular, forms the basis of this article. We’ll also compare Elixir with other programming languages based on insights from our senior backend developer.
If you’re wondering about choosing Elixir for your project, you’re on the right page 🙂
Why is Elixir so popular?
Since its invention in 2011, the popularity of Elixir has been growing wildly. According to the recent data from the Stack Overflow survey, Elixir ranks second among the most loved programming languages, with 75% of developers confirming they will continue using it.
Elixir owes its popularity primarily to the excellent combination of the Erlang Virtual Machine (VM) performance, which it was built on, and the simplicity of Ruby-like syntaxes, which made it easy to learn.
Thanks to Elixir’s high concurrency and low latency, it’s widely used to build large-scale, high-loaded platforms in the telecommunication, eCommerce, crypto exchange, and banking industries.
Five core benefits of using Elixir for development
The decision to run web development with Elixir resulted in cleaner code, more speed, bigger scale, and greater performance for many companies:
- Pinterest cut their lines of code ten times their original length and halved the number of servers
- Moz managed to use 63 times less disk space and 20 times faster API
- Bleacher Report reached eight times more traffic
- Discord, which successfully handled 5 million concurrent users
- WhatsApp, which processed over 50 billion messages per day
Let’s find out how you can use Elixir features to benefit your project.
Elixir was built on Erlang. Its VM automatically isolates and cleans up dysfunctional parts of code and system memory while keeping the system working. It means if you build a website or mobile app with Elixir, its algorithms will fix runtime errors with robot precision and recover without human input.
If your project involves handling multiple tasks simultaneously, Elixir is second to none. Its concurrency model is maintained by Actors, standalone processes that can send and receive messages between each other. Actors are lightweight entities and communicate through asynchronous message passing.
Many programmers consider Elixir to be faster than Ruby and Node.js largely because Elixir is compiled into byte code in the form of .beam files which then are run on the Bogdan Erlang Abstract Machine (just another name for the Erlang VM).
Erlang and BEAM were designed in 1986 by Joe Armstrong for the Ericsson telecommunication company to handle large telephone exchanges with hundreds of thousands of users simultaneously. Backed by such a powerful beast, Elixir can help you create smaller file spaces, reduce your used disk space, and significantly improve the speed of your APIs.
For Ruby-versed developers, learning and using Elixir for web development is relatively easy. Elixir boasts its clear syntax rules and easy code sets with proper documentation. Its libraries are well-designed, the language is functional, and the final code is highly readable.
Through Elixir, you can access all Erlang’s BEAM central processing units (CPUs) and hardware, including multi-core CPUs. More so, Elixir’s Garbage Collector (GC) works very smartly, never overloading the system. Instead of cleaning all the processes, it destroys small processes that are already completed. This way, traffic management is Elixir’s winning point, too.
Now let's compare Elixir with its closest competitors.
Elixir vs. other programming languages
Elixir’s most evident rival is Ruby. But due to high concurrency, Elixir is used for projects with real-time communications or where you need to parallelize data processing while Ruby is suitable for projects that contain plain admin panels, login/signup, and simple APIs — in a word, uncomplicated web apps.
The Ruby on Rails framework is bulky and outdated, and its team is aware of this. But since they have a tremendous number of users, they are hesitant to add any new methodologies and tools so as not to break the old ones, thus experiencing great stagnation.
The inability to make sufficient updates was why Ruby creators decided to move to Elixir and build the Phoenix web framework. So now, a lot of what is missing in Rails can be found in Phoenix.
When it comes to competition, Elixir is often compared with Rust, Scala, and Go.
We’ve asked our senior backend developer Artem about cases of using these programming languages compared to Elixir. Here’s what he said:
- Rust vs. Elixir. Rust is used for system programming. It is used for the backend of low-level post-terminal programs, video card drivers, system utilities, low-power smart home automation solutions, etc. Rust is low-level and writes code directly to the system. Elixir takes up more memory since it carries a virtual machine with it. But it takes longer and it is harder to develop a website with Rust than with Elixir; you have to write a lot manually.
- Go vs. Elixir. Go works well with highly-loaded systems. But unlike Elixir and Ruby, Go is more difficult to understand. Its syntax and the approach to coding are vastly different — many things developers need to write themselves.
- Scala vs. Elixir. Scala is based on Java and has a similar paradigm to Elixir’s yet a different syntax. Like Elixir, Scala relies on the Actors model for concurrency. Still, Scala is not as popular as Elixir.
Find more similarities and differences in the following Elixir comparison chart:
|Futures and Actors
|Global Interpreter Lock (GIL)
|Dynamic with optional types
|Strong and static
|Strong and static
|Strong and static
|Small but active
|Large and active
|Large and active
|Large and active
|Ecosystem and Libraries
|Distributed systems, web development
|Systems programming, game development
|Web development, systems programming, DevOps
|Big Data, web development, machine learning
|Web development, scripting
It often happens so that some projects require using a combination of several programming languages. For example, Discord, initially developed in Elixir, stumbled upon a roadblock with immutable data structures. In 2019, Discord used Rust to solve the issue, and as a result, it could reach 11 million concurrent users (a double increase compared to the Elixir-only stack).
One more example from our practice: To build a cryptocurrency exchange platform with a user-friendly web interface, we used a hybrid approach where we wrote system modules on Elixir, and in contrast, API for the interface on Ruby.
How to define which programming language is better for your project
Picking the right tech stack for an app or a website happens at the initial discovery stage of the development process, or rather, when a team drafts functional and non-functional requirements. You need to consider the load of your system, user traffic, number of simultaneous connections, and more.
In this case, hiring a seasoned software development team not limited by the tech stack they're used to but flexible and ready to master new technologies, is a must.
“Some companies are limited by their tech stack, meaning they try to solve problems in the context of their tech stack. A customer is in luck if the tech stack is appropriate for solving those problems. Otherwise, they could receive a workable yet vulnerable product that won’t pass stress testing when millions of users exchange millions of messages simultaneously. And when the project cracks or starts to process very slowly — then the team’s tech scarcity will backfire.”
— Anton Baryshevskyi, Business Development Officer and Co-Founder at Mind Studios
Defining non-functional requirements and picking the right technology from the get-go are vital for the success of any software development project.
Likewise, it's critical to choose the right development company that prioritizes making high-end products to working on the pipeline principle — and Mind Studios is one such company.
Projects where we prefer Elixir development
Real-time communication via WebSocket protocol, multithreaded connections, and multifold concurrent processes are what Elixir is used for in web development. And the following three projects we made are about those use cases:
A secure messaging app aimed to compete with WhatsApp
Being aware of our client's goals, we knew we were going to build a secure messaging app that would compete with WhatsApp in the Middle East region. In the non-functional requirements language, our messenger needed to maintain tens of thousands of connections at the same time.
We also knew that Ruby on Rails we preferred to use couldn’t fit those requirements. Ruby can handle up to 3,000 active connections to the server. If there are more simultaneous connections, then the following can happen:
- delivery time for messages increases (1 sec => 20 sec)
- connections may be unstable or completely interrupted
Since WhatsApp and Discord were written on Elixir, we decided to switch to it. Our developers quickly mastered the new language.
Since then, in projects with large data sets where the speed of data processing and recording into a database are critical, we use Elixir and appropriate frameworks like Phoenix that are honed for low-latency distributed systems.
Cryptocurrency exchange web development in Elixir
For this project, we needed to provide links to crypto rates from multiple exchanges. In other words, we needed to parse a lot of cryptocurrency exchanges and show the user where to buy bitcoins and where to sell them to earn as much delta as possible.
It included aggregating a lot of data from necessary exchanges, doing some calculations in parallel, and making tons of requests to servers — all that Elixir can handle perfectly.
That doesn’t mean Ruby can’t do a parallel job. It can, but its quality is lacking. Ruby 3.1.0 has received improvements in terms of concurrency, but they're still in beta.
Elixir for game development: CyberHero
CyberHero is an online multiplayer cyberpunk RPG shooter. It’s a turn-based game where two players can play online, taking actions one by one. When player no.1 has finished their move, the other will get a notification so that they can perform their act. Also, players can communicate with each other in real time.
We used Elixir for the server of this turn-based game.
The value of Elixir for mobile apps and websites is undeniable. However, despite Elixir’s advantages, it still has drawbacks, so it can’t be similarly effective for all projects.
The key to developing a robust software product lies in partnering with an experienced software development team with an Elixir-rich portfolio. They can help you pick the right technology stack and save you money.