It feels like a new language, library, or framework is popping up every day. It can be tough to keep up or to decide which is worth your time to learn and implement. But when the community-at-large rallies behind one of these new tools, it’s usually a sign it’s worth checking out—which is the case with the Elixir programming language.
Non-developers don’t always need to keep up with the latest programming trends, but sometimes it can be helpful to know the landscape, whether your team is developing new software from scratch, looking to improve performance with new modules, or working out a budget. Knowing what’s out there can be a good roadmap—especially when it comes to hiring developers skilled in those areas.
When it comes to general-purpose functional programming languages, there are plenty to choose from, each with their own strengths—Elixir may not have the near-ubiquitous presence of Python or PHP, but support for this six-year-old language within the dev community is growing. Its creator came from the Ruby on Rails team with the goal of creating a language with high concurrency and low-latency—your first tip to what Elixir (and an Elixir programmer) does best.
Elixir is dynamic
The goal was to take the best of both worlds from the Erlang and Clojure programming languages, so here’s where it resembles the dynamic Erlang. It’s high-level and executes at runtime.
Elixir is a functional programming language
What is functional programming (vs. procedural programming)? In short, it’s a style of programming (or, a paradigm) that focuses on using expressions to transform data in a way that’s simple, concurrency-safe, and without “side effects.” It’s like a math equation in that you’ll always get the expected result. It’s a tool suited for certain types of jobs, but not all. Elixir is an immutable functional language, which means that it’s easy to read and equally easy to build on (so no overhauls of code later on when it needs optimizing for more or bigger tasks).
Concurrency is the primary goal
Concurrency refers to how well a large number of processes can be run at the same time, independent of one another while mitigating side effects—and it’s the primary benefit of Elixir and its associated use of the Erlang virtual machine (EVM). Imagine a bank of elevators is your software. Without concurrency, only one elevator would be able to process a request to go to a floor at a time, which would hold up all the other people waiting for elevators. In software, concurrency processes multiple requests to the system in real time, keeping things organized and flowing. Furthermore, Elixir processes (not to be confused with OS processes) avoid issues associated with managing shared data and state across multiple processes, by ditching shared memory altogether and relying on asynchronous message passing instead.
Elixir is for scalable, maintainable applications
Elixir code is lightweight and easy to test, and its efficient use of machine resources makes vertical scaling easier to achieve. Also, the way processes can communicate with each other across the same network makes Elixir especially good for horizontal scaling.
Elixir runs on the EVM
The Erlang community has officially accepted Elixir, which was designed to run on the Erlang VM (or, “BEAM,” which is extremely well-suited for both distributed web development and embedded systems like the Internet of Things devices). This gives Elixir access to the Erlang ecosystem, functions, and the “battle-tested” benefits of its VM, which is good for:
- Low-latency. You want to prioritize low latency when your software is processing a high volume of data that are constantly changing with real-time speed (so, not a lot of delay).
- Distributed systems. We’ve discussed how virtualized servers distribute software horizontally across nodes; this VM provides a good foundation for that.
- Fault-tolerance. When parts of software do go awry, supervisors within Elixir allow those parts of the software system to restart and get back to working order.
Why use Elixir?
Developers who use a language can always say it best, like an Elixir forum contributor who said: "chances are sooner or later you will have to do something web-related or distributed (even if you have one server with few cores) and that’s where Elixir shines."
More and more organizations are building distributed software—it’s more efficient, safer, reliable, has fewer dependencies, and fuels better use of machine resources. Rather than shoehorn old technologies into new models, using a modern language like Elixir allows developers to build distributed-style software from the foundation up.
And concurrency with low latency, if that’s a big priority for your software, is another draw—but you’re really talking about the benefits of BEAM and Elixir together. Another Elixir forum developer says “Elixir (and all BEAM languages) is great for building systems that may or may not be scaled out over several computers. That’s the purpose of working on the BEAM. If I […] wasn’t concerned about either easily handling concurrency or building systems, I’d choose something else.” So in short, what makes Elixir and other BEAM languages stand out is spreading big software systems over several nodes.