In keeping with my desire to constantly learn, I decided it was time to take on one of these languages. My friend and colleague, Brian O'Rourke, was having a good time of it with Go, which he uses to manage some of the infrastructure for RedisGreen (great service, and this is not a referral link!). I had some other friends having fun with Clojure. I decided it would be a good idea to keep my network diverse, so I dove into Elixir.
Coming from Ruby, Elixir already has immediate appeal in the form of its syntax. The conventions are similar. CamelCasing for modules, snake_casing for variables and functions (not methods!), the do keyword. But the similarities pretty much end there.
What is this Erlang of which you speak?
Call me superficial, but Erlang syntax is objectively ugly in my opinion, and on this I will not be swayed.
But the other nice things he mentioned stuck in the back of my mind as I continued happily building with Ruby and its lovely syntax and horrible concurrency story.
Once Elixir hit my radar, I remembered all the praise my friend had heaped on Erlang and decided to give it a shot.
Elixir is Erlang with sugar...and more
Elixir compiles down to Erlang byte code. Compiled Elixir code will run exactly as fast as (and sometimes faster than, due to compiler optimizations) native Erlang code. It's interoperable with existing Erlang libraries. And it's easy on the eyes. And it comes with a first-class approach to metaprogramming which Erlang lacks. Elixir also attempts to standardize the functions in its standard library so that the data being acted upon is the first parameter, a marked improvement from Erlang's standard library and a boon to Elixir's unique pipe operator |>, which makes so much sense in a functional, immutable environment. Elixir also has an approach to polymorphism that I believe is unique to the language.
Another shining feature about the language is the core community. José Valim from the Rails core team and inventor of Elixir, Dave Thomas the pragmatic programmer and Ruby evangelist in the early days of Rails, and Joe Armstrong who co-developed Erlang itself, all form a great pedigree of professionals to have backing the language. And the community has been very responsive on Github and IRC whenever I've run into issues, for example Chris McCord, the author of the very promising Elixir web framework Phoenix.
If all Elixir had to give was a pretty face for Erlang, I would still find it more than worthwhile. But, in fact, it is so much more.
Another one is the string handling. Elixir has strings, which are really just special binaries, and charlists, which are really just lists of code points. This mainly becomes an issue when working with Erlang's standard library, but it happens.
My hope is that the above two issues will get better over time as libraries are written in Elixir. It's been said that the Erlang standard library, which comes with quite a lot, shouldn't be duplicated or wrapped as it already works well enough. But if I stub my toe on the same bookshelf every time I walk through my living room, eventually I find the time to figure out a solution for the long term.
My last nitpick is that sometimes I don't know whether to reach for Enum or List, or Dict or Keyword. I think this is something I'll eventually get over as I become more familiar with the language, just like with any language.
If you're looking to learn Elixir, I highly recommend Dave Thomas's Programming Elixir. Josh Adams's Elixir Sips is also a great resource for learning what the language can do and inspiring new projects of your own. And once you're comfortable with the language, I have a little side project of my own you can check out to get a look at one way of using Elixir's highly-concurrent approach to grow a little garden.
At the very least, I hope this post inspires someone to try a new language, whether it's Elixir, Go, Rust, or any of the rest. As programmers, it can be easy to rest on our laurels when we've gained a high level of competency doing one thing with a rewarding career to boot, but inherent curiosity is what got most of us here in the first place. Try something new, and I'm sure you won't regret it.