6 months with Elixir and Phoenix

I have been using Ruby/Rails for 8 years and although I’ve used different technologies over that period, I am sure 95% of my time was spent in Ruby/Rails projects. For the latest 6 months, I have been completely immersed in the Elixir world, developing a Phoenix application from scratch, full-time. In this post I will describe my experience and opinion.

In the latest years, I had the chance to use Erlang in a couple projects. I like the language (before you ask, the syntax was never a problem, I like it) and all its features. I mostly worked in projects with Cowboy and Webmachine. While using Erlang I read two amazing books:

Those two books, together with the Erlang documentation, gave me a pretty good understanding about the fundamentals of Erlang and the OTP environment.

Erlang is great language for concurrent, fault-tolerant and soft real-time systems and I enjoy using it. Rails has spoiled me, so I was missing a more complete set of tools that would allow me to use Erlang for day-to-day web development.

I heard about Elixir in the beginning of 2015, but I only spent some time playing with it after finding Phoenix.

I started learning Elixir and from day one I was in love with it. The language simplicity and the tools around it, make it so simple to start using it. I can just imagine the effort and time spent by José to get to a point where the language is simple, powerful and flexible at the same time.

Not long after, I had the chance to start a new project, where I would be responsible for developing a REST API (consumed by iOS and Android mobile apps) and a dashboard system (used by customers). I decided to use Elixir and Phoenix for building it and this decision proved to be successful.

Thanks to the toolset provided by them, it took only a couple of days until I deploy the first feature to production. After 6 months and a number of commits and deploys, I would like to share my experience about using Elixir and Phoenix in production.

Learning Elixir

Elixir is a beautiful language and it brings many new concepts to people that are used to OOP languages. People that had already played with a functional language before, will pick the basics really quick.

It takes a bit more time to get into more advanced concepts of the language/environment, like supervision trees, agents, monitors & links, etc.

I found it really valuable the time I had spent learning more about Erlang.

Learning Phoenix

Phoenix is not Rails and it has no intentions to be an Elixir version of Rails. But if you are coming from Rails (or any other modern web framework), you will find many common places.

You will also learn a lot of new concepts and will be amazed about how simple it is. Different from Rails, where sometimes features are hidden behind magic behaviours, everything that Phoenix does is explicit and easy to follow. I found it really helpful to be able to go deep on the framework internals.

Installing Elixir and Phoenix

Installing both Elixir and Phoenix (on a mac) was really simple. It only took a couple of minutes (and no manual configuration) to install both of them following the official guides.

Creating a new Phoenix project

You can easily create a new Phoenix project running the mix phoenix.new.

Starting the app

Starting your project’s server is also straightforward using the mix phoenix.server.

Development time

Modern web frameworks like Rails and Django enable small teams to build entire projects in a really small time frame. It can only be achieved, because the framework offers built-in components and the community around it shares lots of open source components.

In my humble opinion, Phoenix has everything that a developer is used to find on a modern web framework. It offers built-in components (e.g. routing, database wrapping, view rendering, migrations, testing, static assets management, etc).

Phoenix goes a bit further with channels, enabling soft-realtime features to your projects (Rails 5 brings something similar with Action Cable).

Elixir and Phoenix are quite new, so you shouldn’t expect to find the same number of 3rd party libraries. Although the number is not comparable, the quality of the libraries being developed are outstanding. A basic search at https://hex.pm can give you a good idea about the available libraries.

Deployment

During all those years using Rails, working on different companies world-wide, deploying meant “Capistrano” (now with Docker getting popular, it is changing a bit).

I decided to deploy the project using Elixir/Erlang releases + Ansible (I wrote a post covering this topic: Deploying Elixir releases). It was the most simple and straightforward way I found.

Performance

When you are building an MVP or a small project, performance is never something you should be worried about. That’s one of the reasons why Rails shines. But what if I tell you that you can have the same development experience and time to market without compromising speed? I believe Phoenix has achieved that.

I was amazed with the performance results when running the server locally. I got really impressed when benchmarking the project running on production machines.

To wrap it up, I am betting on Elixir and Phoenix for the future. I believe they are defining a new standard for software development. The capability of offering all the Erlang goodies, using a really nice language and development environment like Elixir does, is the perfect combination for the concurrent and async world we live at.


Are you planning to start a new project or migrate an existent one using Elixir/Phoenix and want some help? I am available for hire.

You might also like

Free book

Today I released "Versioned APIs with Phoenix" free book. It covers three different strategies on API versioning with Phoenix...

Phoenix API versioning: Accept Header

This is the second part of the API versioning series. This post shows how to achieve API versioning using the Accept header...

Phoenix API versioning: URL

API versioning allows you to response with different content, based on the information sent by the client. Let's see how to do that with Phoenix...

Download free e-book

Learn different strategies on API versioning with "Versioned APIs with Phoenix" free e-book