Why Elixir & Phoenix is a great choice for your web app in 2022
Szymon Soppa
1 Dec 2022 (created at 18 Oct 2021)
How to choose the best web programming language and framework for an app in 2022? Is it even possible? I believe it is, and in this blog post, I'll try to convince you why Elixir & Phoenix is the perfect combination you're looking for.
Elixir productivity equals fewer costs
Productivity is still a vastly underestimated feature of a programming language. In general, the majority of apps on the market have to fulfil some business goals and as we all know, the fewer costs we generate, the higher the profit.
The programming workforce is not cheap and that's why productivity matters. Simply put we consider a programming language productive, if we can write less code while delivering the same features. That's why Ruby was brought to life, and while by design it was not a technology that you could use to create extremely performant apps, it actually did one thing very well - it was extremely productive. It actually still is, and that's why you can find so many big apps like Shopify being based on it. So... why not pick Ruby?
In some cases, productivity comes at a cost, and for Ruby, it's a performance & scalability issue and that's how we get to the main character of this blog post - Elixir. One of the key assumptions of this language is to support great maintainability and ease of use while not overloading a developer with mechanisms that when used extensively may overcomplicate the codebase.
However, the above is not the only reason why Elixir is productive. Let's dig deeper into its great productivity capabilities.
It's a functional language
Sounds weird right? For sure, many developers will disagree with it, but after years spent in objective programming, I consider Elixir a holy grail of productivity in terms of ease of use. Once you grasp the basic concepts of this language it's just super easy to use with the functional paradigm which in the end is so easy to describe:
In functional programming language you use immutable data as an input to a function that produces result. The same input always produce the same output.
The core assumptions of the functional paradigm give you confidence as opposed to what you get with Object-oriented programming.
It has a simple construction that does powerful things
The design of this language is very thoughtful. There are two core concepts in Elixir - modules, and functions. Once you learn these, you can write code.
The whole app is organized within modules, which serve as a container to create a domain-based taxonomy of functions. There are no classes, interfaces, header files, and other boilerplate that we don't need to write working and performant apps.
It uses modern programming language solutions
Mechanisms that should be considered top-notch in the web programming world are already here. In Elixir, you can for instance use:
Advanced pattern matching techniques that you can for instance use to create multiple functions versions based on the values of the arguments. How cool is that?
Built-in advanced concurrency handling and straightforward distributed execution of code (thanks to Erlang OTP)
Pipe operators make the functions processing flow incredibly clear
That's just to name a few. In a nutshell, with Elixir you don't have to worry that you use old mechanisms to solve modern problems.
You write less code as a result
Clean and clear architecture design and modern programming techniques used in this language allow you to write less code, just like in Ruby.
Excellent scalability
Elixir is built on top of Erlang Virtual Machine (Erlang VM) and leverages all its benefits. Let me give you a quick description of why Erlang was brought to life:
The Erlang runtime system is designed for systems with these traits:
Fault-tolerant
Soft real-time
Highly available, non-stop applications
Hot swapping, where code can be changed without stopping a system.
Sounds like an every developer dream, right?
According to Cisco: "90% of all internet traffic goes through Erlang controlled nodes" (check it here) and at the same time, there is still huge traffic in telephony systems handled by Erlang VM. Erlang was designed to operate in the type of environment, where high availability, scalability, fault-tolerance, and performance matter.
Why would you care about Erlang in web programming? Well, once your app gains some real traffic, it needs to scale easily and not break at the same time. This is something that many startup founders don't take into account when developing their first Minimum Viable Product (MVP).
You can't pick a programming language only to consider switching it to another one once your app gains popularity. Choosing wisely at this step means much fewer costs in the future and that's where Elixir shines - it's not only productive, but it also allows you to scale. Do you need proof? Discord was able to scale with Elixir to 5 000 000 concurrent users - check the full story on their blog.
Incredible stability
As already mentioned, one of the Elixir traits is the great fault-tolerance ability (inherited from Erlang). Nowadays, it's not really acceptable both for a business, as well as its customers, to stop delivering the digitized product or service caused by downtime.
Let's go through some numbers (source):
In March 2015, a 12-hour Apple store outage cost the company $25 million;
In August 2016, a five-hour power outage in an operation center caused 2,000 canceled flights and an estimated loss of $150 million for Delta Airlines;
In March 2019, a 14-hour outage cost facebook an estimated $90 million.
Not to mention the recent Facebook outage which cost the company nearly $100 million in revenue and caused a significant drop in trust among many users.
As you see, there is no place for downtime these days, and it's yet another feature of a programming language that you should take into account when building your web application. Stability is where Elixir delivers.
Elixir maturity
Some developers will say that Elixir is not mature enough and that it's just a niche language. I disagree. While it's here since 2014 (the first release note can be found here) it would not be appropriate to say that it's just 7 years old.
Elixir is based on Erlang, and it inherits its all benefits and experience. As Erlang exists since 1986 (source) it's safe to say that Elixir in comparison to most well-known web programming languages is the most mature and proven language. You just can't describe Elixir's capabilities without taking Erlang into account.
At the same time, there are big brands using Elixir and Erlang. Let's just name a few:
Discord - Elixir helped them scale, as mentioned here;
WhatsApp - see why they needed only 50 Engineers to handle 900M users here;
PepsiCo - check a great case study here;
Spotify - listen to the story behind it here,
Heroku - case study available here.
It's not only the wide production adoption in big companies that makes it mature but also programming libraries' availability. It's safe to say for me now, that in the Elixir ecosystem you can find a library for almost any use case you need. Sure there might be a need to write some API client code for third-party service, but it's not a case that you would not face with the most popular programming language anyway.
All of this makes me think that Elixir is mature after all.
Awesome Phoenix web framework
Phoenix framework is where Elixir shines. It's built-in a very elegant manner and gives you everything you need to build robust web applications as well as advanced APIs. Once you understand what Plug.Conn is in Phoenix. you start to look at the applications as a group of layers with different responsibilities. That helps a lot.
With Phoenix and Absinthe, you can build modern GraphQL APIs. Thanks to built-in support for WebSocket (Phoenix Channels) you're able to handle even more than 2 million users on a single machine at the same time! How crazy is that?
However, what really distinguishes Phoenix from the rest of modern web frameworks, is Phoenix Live View. It's just an amazing way to built a reactive real-time server-rendered HTML. What does it mean? It means that in most cases, you can forget about writing JavaScript & React. You can stay in the Elixir world and define real-time components on the server-side with no JS code.
There are some good reasons to claim that Elixir is safe.
First of all, Elixir operates on immutable data which in the end means that there will be no side-effects of data processing. This particular characteristic of functional programming languages has some seriously good benefits. It allows you to write and test the code in a predictable way as well as saves you a lot of time on debugging. As already mentioned, there are no side effects with functional languages, which is such a relief.
Secondly, the Phoenix framework has well-defined layers which are much easier to control due to its functional nature. You can clearly see each step of request processing, which makes it way easier to navigate and therefore produce safe & secure applications.
Lastly, if you research the use cases of Elixir you'll see that it's used in Financial services (like Klarna), as well as big messaging applications (like Discord). Commercial big applications that don't break or leak are just great proof of security in Elixir and Phoenix.
The community and developers satisfaction
Elixir community is very helpful and supportive. A quick look at Elixir Forum can prove it. From my perspective, it all comes down to programmers' satisfaction. Elixir is not only at the top of the most loved programming languages but also it's also top paid. It's a great advantage if you think about recruitment.
You can pick a more popular language, but after all, you have to understand that programmers' satisfaction and engagement are what bring results.
Great creators and maintainers
People behind the scene are the power of Elixir. I'm confident to say that José Valim (the creator of Elixir) is mostly the reason why Elixir is such a great language. He is an incredibly intelligent and productive personality and you'll often see him engaging in discussions on Github issues or forums. His experience as a core Ruby contributor paid the dividend in the process of creating Elixir which now combines the best advantages of various programming languages. It's not easy to direct the development of programming language in the right direction. He did great at this step.
Chris McCord, the creator of Phoenix Framework is yet another humble and dedicated person that brings us some great goodies like Phoenix Live View that you can hardly find elsewhere.
Elixir & Phoenix - a great choice for a modern web application in 2022
Looking at the chart of programming language popularity in Google Trends is not enough to pick a programming language for a web application. You have to understand all the features of the technology to make a solid decision. Elixir has it all - productivity, stability, security, and scalability. It's also loved by programmers and big companies use it in production.
Why would you pick a programming language for a web app in 2022 that allows you to create MVP fast but doesn't scale? Pick wisely, Elixir might be the one you're looking for.
Don't forget to share this post!
Sign to our Newsletter
Szymon Soppa Curiosum Founder & CEO
on #curiosum blog
MVP, MBI, MMF and MMR - What is the Difference
You came up with an idea where you see the potential to create your own app. I assume that you are looking for information on the Internet or groups of business environments, how to check if your investment will find users and have sales potential.
Renata Hryniewicz
5 top-tier companies that use Elixir
Elixir is a pretty capable language - and it consistently ranks near the top of most loved and wanted languages rankings. It has a large following and some very persuasive preachers as well. But that would not be enough to make me like it – what I need as real proof of its strengths is real businesses that strive with Elixir.
That's what this list is all about – a bunch of stories from top companies that chose Elixir and never looked back. Let us show you how its power and versatility shows in practice.
What is an MVP and why Elixir is a perfect language for building a minimum viable app?
Ok, so you are planning to change the world! You have an amazing idea for a new web or mobile app, but... Did you test it? If not, you should do that! To check if your idea is really valuable for your stakeholders - create an MVP (minimum viable product). What exactly is this?
Natalia Szydłowska