First, a little history...
In the 1980s, Ericsson -- a Swedish telecommunication company -- decided to investigate how to program the next generation of telephony applications. The goal was to be able to efficiently build distributed, concurrent and fault-tolerant real-time systems.
After prototyping applications with all the available languages at the time, Joe Armstrongand his colleagues decided that none of them could meet all the requirements they had, and instead invented their own -- Erlang. Below is a badass video that the Ericsson development team made explaining the advantages of Erlang:
Erlang was eventually open-sourced in 1998, after gaining momentum in the industry. It was however still considered a pretty niche language, reserved for either telecom companies or functional programming enthusiasts.
Fast forward to 2014, and the whole internet goes bananas as we hear that Facebook is buying the relatively new chatting app WhatsApp for $19 billion dollars. Yup, 19 billion. What's even crazier is that it turns out that the WhatsApp team is actually tiny (only 50 engineers) despite their messaging service having 900 million connected users. How did they do it? Well, it turns out that one of their secrets was that they were using Erlang.
Which brings us to today. In a world where new internet services focus more and more on real-time interactions (and have to potentially scale to millions of users), functional languages like Erlang are experiencing a well-deserved renaissance.
Still, the fact that Erlang was designed in the 1980s leaves a lot to be desired. Since then, newer languages like Ruby and Python have spoiled developers with their clean syntax and productive tooling...
In 2011, José Valim -- a long-time contributor to the Ruby community -- was looking for a way to improve the performance of his company's Rails application when he stumbled upon Erlang.
José was impressed by the Erlang Virtual Machine (a.k.a. BEAM), but felt that the language itself was missing some of the flexibility and constructs that he wanted. To tackle that, he built a brand new language on top of the Erlang VM and called it Elixir.
Elixir focused on removing boilerplate code and improving the syntax and tooling so that developers could get "productivity out of the box". In short, it's like Erlang, but with a modern twist and better code organisation.
Some have called Elixir "the next big language for the web" and think that it will take over the world in the same way that Ruby did with the Rails framework 10 years ago. Of course, none of us can predict the future, but what is certain is that the demand for functional programming is increasing. In this category, Elixir is poised to become one of the top choices due to its unique combination of an elegant language and a battle-tested virtual machine.
Alright, enough sales talk, let's get coding!
In this lesson, we're going to install Elixir for macOS, but if you are using another operating system, check out the official Elixir installation page and skip to the next lesson.
In order to install Elixir, we first need Homebrew -- a package manager for macOS.
If you don't have it, open up your terminal application (located in
Applications > Utilities > Terminal), and run this command:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once you have Homebrew, you can use the
brew-command to install Elixir:
$ brew install elixir
When that's done, you can run this command to check that everything's been installed correctly:
$ elixir -v Erlang/OTP 19 [erts-8.2.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] Elixir 1.4.2