Disclaimer: This is not a tutorial for elixir, it’s just a short brief intro of what elixir could do and why it matters
So the past couple of weeks I have been playing with elixir. it’s actually pretty good and how it has evolved over the years, seems unbelievable!!!!, I have followed some functional programming techniques in OOP languages but i never truly understood what i could even further do with that.
Elixir is a mighty warrior from the world of Functional programming, Learning elixir is easy compared to learning Erlang and to be fair it has inherited everything from Erlang and it runs on Erlang VM (BEAM).
So what can i do with elixir?
Suppose you have an iot device, something like a weather sensor, that is deployed around the world to collect the weather data, maybe around 1 million devices. These devices send the collected data to the server at specific time intervals. For a typical scenario, some may consider doing a rewrite of the existing code base to make it more distributed and scalable for the future.
Well, elixir could do a lot more here, using erlang’s OTP you could actually manage around 1.5 million devices with a 40 Core-Server and the language comes with an addon to make it distributed, Seems amazing right !!!.
This was made possible by using Erlang’s VM called BEAM, you can just spawn process there which is much lighter than any process inside the os. Its easily managed by the schedulers inside the VM. Each connection could have a process to keep the data flow alive. to manage processes modules like gen server comes in play which removes a lot of headaches.
So what happens when a process crash?
“Let it crash”, this is the motto that erlang holds for situations like that, erlangs fault tolerance policy is something that should be appreciated, it has a build in supervisor model which could easily restart the process that’s crashed. We could actually build a hierarchy of processes and supervisors to make the system more fault tolerant.
The whole package comes with scale in mind and it is easy as pie to add more nodes and scale.
Elixir also has a web framework called Phoenix which has everything you need as a Web-dev. It’s fast it’s easy to learn it supports WebSockets and could handle them pretty well, there is a query generator for MySQL and Postgres called Ecto, which takes a bit time to catch up on for someone who has done ORM’S but it’s worth the effort. There are some amazing thing inside the ECTO library that still needs to be explored.
So where to get started?
Read a book, Seriously read some books on elixir it can help in the long run, Watch some conference videos and play with iex (Interactive elixir terminal) for a while, Max out your Desktop or laptop and learn how to crash it.
(after all the only way to learn something is to break it apart )