📜 You can read the Indonesian version here!
Table of Contents
- Elixir Language
- Improvements Brought by Elixir
- Elixir’s Drawbacks
- Learning Resources for Elixir
- References
Elixir Language
If Erlang is already very capable, why do we still need to learn Elixir?
The answer lies in the improvements Elixir brings to the developer experience and overall productivity.
Elixir is a functional programming language designed to help us write cleaner, more concise, and more expressive code on the BEAM virtual machine. With its modern syntax and a design focused on developer comfort, Elixir makes it easier for us to read, maintain, and develop applications.
Elixir code is compiled into bytecode that runs on the BEAM virtual machine, just like Erlang. Since it’s built on the same foundation, Elixir is fully compatible with the existing ecosystem. We can use Erlang libraries directly in Elixir projects, and vice versa. This is very helpful when the library we need doesn’t yet exist in Elixir, allowing us to use mature solutions without having to rewrite them from scratch.
But Elixir is not just about compatibility. It simplifies many aspects of writing Erlang code. Elixir reduces repetitive code and offers modern tools such as:
- Mix for project management, testing, and compilation
- Hex as the official package manager for the Elixir ecosystem
- Built-in documentation, automated testing, and debugging utilities that support modern development workflows
With all these advantages, Elixir brings the power and reliability of Erlang in a more developer-friendly form, including for beginners like us who are just getting started with the ecosystem. This makes Elixir an attractive option for anyone who wants to build large-scale, fault-tolerant systems on top of the BEAM.
Just like Erlang, Elixir is an actively developed open-source project. It was created by José Valim, and its source code is available in the elixir-lang/elixir GitHub repository.
Improvements Brought by Elixir
One of Elixir’s biggest strengths is its ability to significantly reduce boilerplate and syntactic noise. Code written in Elixir tends to be simpler, more expressive, and easier to maintain.
In Erlang, boilerplate is often unavoidable due to syntax limitations. Elixir solves this by introducing various forms of syntactic sugar and modern writing styles that make the code more pleasant to read and write.
Even though both Erlang and Elixir are functional languages focused on data transformation through functions, the way we structure program flow in Elixir feels much more natural. One of the most noticeable differences lies in how we chain function calls. In Erlang, data is usually processed in a nested manner from the inside out, a style often called "staircasing." When many functions are used in sequence, the code becomes hard to read, especially for beginners.
Elixir simplifies this pattern by introducing the pipe operator (|>
). This operator allows us to write data flow from left to right, or top to bottom, following the actual order of execution. The result is more readable code that flows logically.
Here’s a comparison:
Erlang (staircasing):
Result = process3(process2(process1(Input))).
Elixir (pipe operator):
input
|> process1()
|> process2()
|> process3()
In addition to the pipe operator, Elixir brings many other improvements that enhance the development experience as a whole. Features like built-in documentation, an interactive REPL, and complete development tools are available out of the box.
For example, documentation can be written directly in the source code using @moduledoc
and @doc
annotations. This documentation is treated as a first-class part of the code. It can be accessed from IEx, converted into HTML or EPUB using ExDoc
, and even executed as part of tests using the doctest feature.
For daily development, Elixir provides Mix, a unified tool for managing projects, dependencies, compilation, testing, and other common tasks. Mix integrates directly with Hex (https://hex.pm), the official package manager in the BEAM ecosystem, making it easy to use and share libraries with the community.
In short, Elixir brings the power and reliability of Erlang into a development experience that is more modern and enjoyable. With all these features, Elixir helps us write efficient, well-structured, and well-documented code from day one.
Elixir’s Drawbacks
No technology is perfect, and that includes Elixir and Erlang. It’s important to understand their weaknesses and limitations so we can decide whether Elixir fits the needs of the project we’re building.
Performance: Not for Raw Speed
One of Elixir’s key limitations is execution speed. Since it runs on the BEAM virtual machine, Elixir cannot match the raw performance of languages like C, C++, or Rust that are compiled directly to machine code. If your application is CPU-bound, such as for image processing, machine learning, or video encoding, Elixir may not be the ideal choice.
However, this is not a design flaw. It’s a deliberate architectural decision. BEAM is not built to be the fastest in terms of raw throughput or requests per second like Rust. Its focus is to stay stable under heavy load, provide fault tolerance, and handle massive concurrency efficiently.
If part of your application needs high performance, you can write that part in another language like C or Rust, then integrate it using NIF (Native Implemented Function). This lets you get performance benefits without leaving the BEAM ecosystem entirely.
Ecosystem: Still Smaller Than Popular Languages
The Elixir ecosystem is still relatively small compared to other popular languages. For comparison:
- Hex, the official package manager for Elixir and Erlang, offers around 20,000 libraries
- Packagist for PHP has over 400,000 libraries
- NPM for JavaScript and TypeScript has over 3 million packages
This means that during development, we may encounter situations where the library we need hasn’t been built yet. This can slow us down, especially if we’re used to working in ecosystems that provide packages for almost every use case.
Aside from Elixir libraries, we can also use libraries from Erlang or other BEAM languages like Gleam. All of them are interoperable and complement each other well.
Positive Trend: Community and Interest Keep Growing
Even though Elixir’s ecosystem isn’t as large as JavaScript or Python, interest in Elixir is growing steadily. In the Stack Overflow Developer Survey 2024, Elixir ranked second among the most desired languages after Rust. Phoenix, Elixir’s main web framework, even ranked first in the web frameworks and technologies category.
This shows that more developers are exploring Elixir, and many are likely to contribute to the growth of its ecosystem. The Elixir community is also known for being friendly and welcoming to newcomers, which is a big help when learning or migrating from another language.
Learning Resources for Elixir
The main source for learning Elixir is its official documentation, especially the Getting Started section. There, we can learn the fundamentals of Elixir, from syntax and data structures to core concepts.
In addition to the documentation, the book Elixir in Action (3rd edition) by Saša Jurić is also highly recommended. The book is divided into three main sections: the language fundamentals, concurrent programming on the BEAM, and real-world production use. This makes it a complete guide for anyone looking to understand Elixir deeply.
For those who prefer learning visually, several video-based resources are available. The ElixirCasts series and Elixir Mentor YouTube channel offer short and focused videos that explain Elixir topics clearly and directly. This format is great for quickly strengthening practical understanding.
With all these learning paths, we can choose whichever suits us best, whether that’s documentation, books, or video tutorials.
References
- Saša Jurić. (2024). Elixir In Action (3rd ed.). Manning Publications.
- Stack Overflow. (2024). Stack Overflow Survey 2024: Admired and Desired Technologies. https://survey.stackoverflow.co/2024/technology/#admired-and-desired
Top comments (0)