Playing with Elixir

Playing with Elixir
Photo by Luca Bravo / Unsplash

Recently Elixir and their web framework Phoenix has been picking up lot of interest, especially from HN. I decided to take a look and it looks very exciting. Some time back when I was playing with XMPP, I came across Erlang. But it had a very deep learning curve and the syntax was off-putting at that time.

Elixir runs on the Erlang VM giving complete access to Erlang’s ecosystem and has better syntax. Apart from approachable syntax, here are the three things which are exciting for me.

  1. Pure functional language.
    I come from a JAVA world, recently I have been playing around with Scala and the idea of functional programming is tempting.

  2. Actor based.
    In work we have been doing a lot work with AKKA actors and it seems excitingly simple and efficient for some of the distributed, fault tolerant tasks without any complexities of multi threaded application.

  3. Channel.
    From Phoenix documentaion "Channels are a really exciting and powerful part of Phoenix that allow us to easily add soft-realtime features to our applications. Channels are based on a simple idea - sending and receiving messages". The default transport mechanism is via WebSockets which will fall back to LongPolling if WebSockets are not available and there are javascript,SWIFT and Android client.

Best way to learn something new is always by doing. Back in 2012 I was building an online test preparation platform with collaborative features. Basic Idea was students should be able to join study groups and once they start a study session, everyone in the group gets questions and they can answer/discuss in realtime. And there would be an admin bot which will manage the session like delivering questions, keeping the score board, ban/block users, etc.
Initially we found XMPP fitting perfectly for our requirment. We picked ejabbered as the XMPP server and strophe.js on client and in the backend we used Smack library from openfire.
Our main application was in PHP MYSQL, and XMPP server in Erlang, there was another backend code written in JAVA. We faced a lot of issues gluing all the systems together.
Later we had complete re-write in nodejs and socket.io. Architecture and development became much simpler since both server and client where running javascript.

I will be trying to build a POC for the above mentioned using Elixir(Phoenix framework to be precise) and may be an Android/iOS client too if I get enough time.