Elixir And Phoenix

26Jun, 2018

Elixir

Elixir is a functional language. It has no classes, only modules with module functions. It was created by Jose Valim. An ex-member of Rails core team. Jose took Erlang language and mix it with ruby and generate its Ambitious Elixir language.

Main difference between Elixir and Ruby

As Elixir was created by ex-member of rails. So It has some differences from ruby,

  • Elixir is a compile language. It code compiled to Erlang byte code and runs by Erlang VM.
  • It is fast and light
  • As it is related to Erlang, so it has inherited all the Erlang advantages

Erlang

Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability.

Phoenix

Phoenix is production web framework that does not compromise speed and maintainability. Phoenix is an MVC framework build on Elixir. And It has a lot in common with Rails. Some are written below

  • It has dependency system like in Rails.
  • It has task manage called as ‘mix’ just like Rails’s ‘rake’
  • It has scaffold generator
  • Testing is also available
  • For db manipulation, it uses ‘Ecto’ instead of ActiverRecord.

It is very useful in real time application due to Erlang VM called as beam.

Beam

The BEAM runs 24×7 on the server. A Ruby (on Rails) process only runs when the web server starts it to answer a request. So if you for example want to do something every hour you have to use cronjob to trigger it on a Rails system. On a Phoenix system this will be taken care of by a little Elixir program in the BEAM. In case you are running a really big web application the BEAM has one really interesting trick up it’s sleeve: It scales super easy over many servers. Scaling is not a source of headaches for Phoenix projects. WhatsApp server run on the BEAM too.