Elixir, the first approach

Mon, Sep 12, 2016 3-minute read

Recently I wanted to experiment with some new technology. I heard good things about Elixir and its Phoenix framework so I decided to give them a try.

They’re a good fit with my goal for several reasons:

  • Elixir runs on BEAM (the Erlang virtual machine). I used actors in other languages but I’ve never used them on a virtual machine designed around them;
  • Elixir is a dynamically typed language. When I write code compilers are my best friends. I’m surely going to miss them;
  • Phoenix is a full-fledged framework while I’m used to work with the smallest and the least opinionated libraries possible.

The outcome has been mixed. So far I spent most of the time reading the documentation of Elixir and Phoenix and I must say that they’re clear and well written.

BEAM, with OTP supervision trees and hot code reloading is a neat. I cannot say anything about its performance but I have no reasons to think they won’t be solid as reported in all the benchmarks I’ve seen.

Elixir itself seems a nice language. I would never choose it over a language with an Hindley–Milner type system (I really hope mlfe will continue to grow) but its immutability, pattern matching and guards make using it bearable. I’ve not written much code in it yet but so far it’s been better than I would have expected.

Phoenix has been what I liked the least from my first glance. Not because it’s bad (it isn’t). It’s just that it’s a framework and as such is very opinionated on lots of things, it hides most of the details and it expects the programmer to know the incantations to have it do what it wants. Everything makes sense (apart from it wanting to use a database to run tests) and it’s well documented, but what I wanted to do was a fairly simple API and I felt it’s not the right tool for the job.

After feeling a bit disoriented by Phoenix I had a look at Cowboy and I found something simpler and lower level, which is closer to what I generally prefer: lightweight libraries like Suave.io and use them as one of the building blocks for my applications. I prefer to have more control on what’s going on.

At the end of the day I can say that I enjoyed looking at something different. These first experiments didn’t convert me to Elixir but it has been interesting enough to look into it. It didn’t became my go-to choice for my side projects but I’m surely going to experiment with it a bit more.