Read time 3 min
This post is based on the observations made while working with Elixir over an extended hackathon weekend, Reaktor Code Camp. Prior to the event, none of us in the team had any practical experience with Elixir or Erlang, a platform on which Elixir heavily builds upon.
As said, Elixir has a very tight integration with Erlang. It runs on Erlang virtual machine and has no performance or practical syntax overhead when calling Erlang code. As Erlang was developed at Ericsson already back in 1986 for their telecom applications, the language and the VM have been running in high-availability settings for a very long time now. More recently, Erlang has been used to implement game servers, distributed databases and, unsurprisingly, messaging services.
Elixir language reached version 1.0 in September 2014, so you shouldn’t be bumping into any breaking changes in case you’re looking to build something more permanent with it. You could call Elixir a facelift for the more low level and older Erlang, as many updates just streamline the usage instead of changing the design altogether.
Our practical findings came from solving the code camp assignment, which required each team to implement an AI. Each implementation would communicate using JSON over UDP. In order for anything to happen, the teams had to solve how to implement network sockets, JSON de/serialization, and AI logic in their respective programming languages.
Networking in our implementation ended up using very Erlang-esque approach, the “GenServer”, a specification for implementing messaging servers on Erlang. We also tried a library abstraction for sockets, but as we came to terms with the platform, we ended up discarding the library and going with the more native approach.
For processing JSON, we used a package called Poison. Lucky for our team, JSON data types could be mapped directly to the ones of Elixir, so we didn’t have to spend any time for custom deserialization. Earlier code camps have shown that handling JSON with less expressive or strictly typed languages could eat a considerable chunk of time from the little time you got.
We didn’t encounter any challenges with the AI implementation. We used the Graphmath package for vector calculus just to save some time not implementing the missing pieces ourselves. Due to the tight schedule, we couldn’t invest as much time into the concurrency as we would’ve wanted.
To conclude: if you have some time and you are interested in distributed computing, Elixir is a language that is easy to recommend trying out. As the Elixir community hasn’t been around for that long, you’ll also need to work with Erlang modules and documentation after the beginning. If you’re already experienced in Erlang, you should feel right at home after checking out the Elixir crash course.
Our top picks to summarize our first experiences with Elixir and, indirectly, Erlang:
- One-liner toolchain setup for REPL, build tool, and Erlang platform dependency
- Erlang VM has been around for a long time and seen a lot of action
- Immutability, functional paradigm, shared nothing architecture, extensive pattern matching support
- Up-to-date community packages can be a bit of a scarce resource
- Being so tightly knit with Erlang can be confusing at first
Code Camp Elixir team: Teijo Laine, Jani Rahkola, Esa Virtanen, Iivari Äikäs
Sign up for our newsletter
Get the latest from us in tech, business, design – and why not life.