I started fiddling with Elixir about 1.5 year ago. Today I feel like sharing my experience with the language.
I’ve been coding with Ruby for the past 5 years (mostly around the Rails ecosystem) and I try to learn a new programming language every year.
2016 is definitely the year of Elixir for me.
My original curiosity for the language, unfolded to a quest to learn about distributed applications following the path of Erlang.
Fellow Alchemists marching to the land of OTP
My first experience with Elixir came when at work my team was looking for a web application framework to receive enormous loads of Analytics traffic (see related analytics-blogpost).
We investigated many options in nodejs, Erlang, Clojure and Ruby. We ended up using Goliath, an Event-Machine based web server framework in Ruby for team productivity reasons (team consisted of .
Upon considering Erlang and Chicago Boss, I also found out about Elixir and Phoenix (which was just released at the time) and both caught my eye.
The first things that came to my mind, initially fiddling with Elixir were:
- Oh it looks a lot like Ruby, neat!
- How can I define a class? What do you mean there are no classes here?!
- Does everything have to be so explicit? Why do I have to alias all the things?
- The REPL (iex) does not keep history? Are you kidding me?
- Seems like a trap for rubyists to adapt to functional programming practices
So why did I invest my time trying to master it?
Well, José Valim has made tremendous efforts in organising and maintaining a healthy community around the language.
A lot of renowned rubyists have acknowledged the struggle to mend the things ruby is bad at. José has created an evolved ruby, a new language, which is so new yet already feels mature and practical.
I bet on the future of Elixir not only because of the features, but because I can see others share the same enthusiasm as mine, cooperating in harmony on open-source projects of the ecosystems, being nice to each other. The github repo of the language already has almost 500 contributors, that’s incredible.
I’m pretty sure others have covered the features of the language in great detail, if you haven’t read “why Elixir” by Saša Jurić, I wholeheartedly tempt you to give it a look.
Elixir runs on the Erlang VM and integrates beautifully with OTP which is trusted by many companies to build resilient, performant, distributed applications.
For those unfamiliar with OTP, it’s a development environment for concurrent programming, featuring:
- The Erlang interpreter and compiler
- Erlang standard libraries
- Dialyzer, a static analysis tool
- Mnesia, a distributed database
- Erlang Term Storage (ETS), an in-memory database
- A debugger
- Observer, a GUI with information about characteristics of the system
- An event tracer
- A release-management tool
Elixir applications are meant to be build upon the principles of Erlang:
It’s an expressive language, easily extensible using hygienic macros.
Defining a parallel map function is as simple as:
defmodule Parallel do
def pmap(collection, func) do
|> Enum.map(&(Task.async(fn -> func.(&1) end)))
(snippet taken from elixir-recipes)
Elixir focuses on the points where Ruby arguably is lacking more, having a homey syntax for rubyists (compared to Erlang).
I also find it important that Elixir ships with a build tool (Mix), a testing framework (ExUnit) and offers intuitive interoperability with Erlang.
The community is amazing. We call ourselves alchemists and I really like the mystery vibes around the name.
On all the above platforms, I found people to be responsive to questions, nice and talkative. The community seems to be blooming, slack has already more than 11.000 members with ~1000 of them active at any time.
Elixir makes pattern matching more approachable.
As stated in Introduction to Functional Programming (1992)
Pattern matching is one of the cornerstones of an equational style of definition; more often than not it leads to a cleaner and more readily understandable definition than a style based on conditional equations. (…) it also simplifies the process of reasoning formally about functions.
Since most people are familiar with equational style of definition from math, pattern matching seems like the natural way to adapt from math to programming.
My Progress so far
- Solved some adventofcode exercises using Elixir to familiarize myself more
- Read Introducing Elixir
- Wrote an API client for work (skroutz.ex)
- Talked about Elixir at Athens Ruby Meetup (presentation)
- Been at Elixir meetups in Berlin and London
- Read Programming Elixir
- Created and maintain Kitto and open-source framework to create dashboards
- Read Elixir in Action
- Read Metaprogramming Elixir
- Read Concurrent Programming in ERLANG
- Read programming phoenix
- Finish reading The Little Elixir & OTP Guidebook
- Dive in deeper in OTP and read more Erlang books
- Give GenStage a try
- Improve and extend Kitto
- Blog about Kitto (stay tuned)
- Release a project I’m working on these days (hint: CI for packages), built with Phoenix
Feel free to make reading suggestions and comments on the reddit post.