When to Leave Elixir
Let’s learn about some of the benefits and drawbacks of using Elixir.
We'll cover the following
Advantages
-
The BEAM gives us a toolkit, which means we don’t need external dependencies as often as many other environments do.
-
It’s rare to need memcached or Redis for ephemeral state with ets built-in.
-
If we need a worker pool or a background job system, we can probably meet our exact need with around 100 lines of code. If we want to save even that, some libraries handle the general case for us without leaving the VM.
-
There are some advantages to having all of this with the rest of our app as well. The same data structures work everywhere, we get to use supervision, it’s easier to react to subsystems becoming unavailable, and so on.
-
The BEAM is closer to an operating system than most programming language runtimes, so building out various kinds of processing with it is much easier.
Disadvantages
-
Elixir datatypes are suitable for many problems, but not all. Data structures built with those types are not always efficient. The classic example is number crunching. If we find ourself working with arrays that need to update frequently and randomly, we should consider integrating a third-party solution into our program. Such integration strategies are outside the scope of this course.
-
A great example of when to leave Elixir is an SQL database. Most projects need one, and there’s so much we can gain from it—ACID compliance, transactions, table joins, the list goes on and on. More importantly, it’s helpful to scale our database separately from our production Elixir deployment.
Get hands-on with 1200+ tech skills courses.