Hello, and welcome. I'm Josh Adams, and I'm happy to introduce you to Elixir
Sips - a new screencast series that will walk through learning Elixir from the
ground up, and will move on to more advanced topics within Elixir as time goes
on and we all get better with the language.
What is Elixir and why are you interested in learning it?
In the words of the Elixir website,
Elixir is a functional, meta-programming
aware language built on top of the Erlang VM. It is a dynamic language with
flexible syntax and macro support that leverages Erlang's abilities to build
concurrent, distributed and fault-tolerant applications with hot code
In general, I find it interesting because of three things:
- I find the Actor Model of computation very compelling, and Erlang's where it's
had the most time to grow.
- Being built upon the Erlang VM, it should be possible to write extremely
reliable, distributed, concurrent systems in it.
- The syntax is far more approachable for beginners than is Erlang's syntax.
These three points combined should lead to a massive growth in the language, and
I'm excited about that.
Who am I and why am I qualified to take you along as I learn it?
My name is Josh Adams. I'm the CTO of a software development consultancy,
built financial systems that handle billions of dollars worth of transactions
each year. That's about all of the horn-tooting I'm comfortable doing. The
point is, I've finally gotten to the point in my career where I feel comfortable
saying that I'm quite good at what I do.
However, Elixir qualifies firmly as something I don't do - at least yet. I've
only very recently begun learning Erlang itself. However, I've built a currency
trading platform that is based on the Actor Model in Ruby, using the Celluloid
ecosystem that Tony Arcieri wrote. Consequently, I'm pretty firmly comfortable
with building large systems using the actor model, but I'm also pretty much a
rookie when it comes to Elixir.
I think that places me in an ideal situation to be useful in teaching people
Elixir, by them following along as I learn it.
Assuming you're convinced by all of this, let's get started learning.
The only prerequisite for installing Elixir is Erlang, since Elixir runs on the
Installing Erlang is exceedingly simple. There are instructions and downloads
available at the main Erlang site, but I
think the easiest way to get started is to download a precompiled package
provided by the fine folks at Erlang
There are downloads for various operating systems there. Since I use Ubuntu
Linux, I'll just walk through the installation procedure on my machine. If
you're on a Mac or Windows, just download and install the provided package and
skip to the bit where we verify that the installation worked.
First, I add a file with the ppa to /etc/apt/sources.list.d/erlang.list:
deb http://binaries.erlang-solutions.com/debian raring contrib
Next, download and add the Erlang Solutions public key to the apt keyring:
wget -O - http://binaries.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -
Then update my list of available packages:
sudo apt-get update
Finally, install the erlang release that is provided in that ppa:
sudo apt-get install esl-erlang
You can verify that the installation worked by entering an Erlang Shell. At a
console prompt, type
erl and you should be greeted by something that looks
Erlang R16B01 (erts-5.10.2) [source-bdf5300] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.2 (abort with ^G)
If you see that, congratulations - you've installed Elixir's entire prerequisite
q(). and press Enter to exit.
There are various precompiled packages, but it's very easy to build Elixir from
source. I'm going to build it from source, but feel free to download a package
if that's your preferred way to get software onto your system.
First, download the latest stable release of Elixir at the elixir github
repository's tags page. At this
moment, that's v0.10.1.
Go ahead and uncompress the download wherever you prefer to keep your source
cd into the Elixir directory.
Finally, just run
make and Elixir will be built. You'll end up with some
binaries in the
bin directory. The suggested next step is to add that
directory to your
PATH. Personally, I just do a
sudo make install and
install them in the appropriate location for binaries on my system.
Firing up iex
To verify that your Elixir install was successful, type
iex. Assuming you did
everything right, you should be greeted with a prompt that looks like this:
Erlang R16B01 (erts-5.10.2) [source-bdf5300] [64-bit] [smp:4:4]
[async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (0.10.1-dev) - press Ctrl+C to exit (type h() ENTER for help)
Just press Ctrl+C twice to close the shell out.
That's it, you've successfully installed Elixir. See you soon.
Where can you get more help with Elixir?
- There's an IRC channel: #elixir-lang on FreeNode
- There's a Google Groups mailing list called
- The Elixir Website is extremely well done and has
lots of nice information.
Notes on installing on Windows
A nice subscriber, Greg Houston, sent in some notes on installing under Windows.
I'm adding them to this episode's notes for posterity. Thanks Greg!
Here are some notes on the Windows install...
1) Use the prepackaged binary for Erlang. The installer works great.
2) You have to manually add the bin folder for Erlang to your PATH environment
3) The prepackaged binary for Elixir is a zip file you have to manually unzip.
I unzipped it to
4) You have to manually add the bin folder for Elixir to your PATH environment
Notes on installing on Mac
Another nice subscriber, Errin Larsen, sent in some notes on installing on a
Mac. There are Homebrew packages available for Erlang and Elixir.
brew install elixir is broken - I used
brew edit elixir and followed this commit's changes to fix the problem
What is the Actor Model?
I had a subscriber ask me for a succinct explanation of the Actor Model.
Without getting too deeply into it, I'd describe it thusly:
An actor is an object that has its own lifecycle and lives concurrently. An
actor communicates with another actor by placing a message in his mailbox. The
second actor can then read the mailbox in his preferred order, and respond to
the messages at his leisure. This is a large part of the Erlang 'shared
nothing' model, and one of the core concepts that leads to its fault tolerance
and ease of distribution.
If you want more details, there's an excellent video that MSDN's Channel 9 did
interviewing Carl Hewitt, Erik Meijer, and Clemens Szyperski on the actor