A Drop of Elixir

A short introduction to Elixir

Paweł Duda (@paweldude)



  • Made by Ericsson to improve telephony applications (1986)
  • Runs on BEAM (Bogdan/Björn's Erlang Abstract Machine) VM
  • Open-sourced in 1998

Who even uses it?



  • Facebook: chat backend, 100m active users
  • WhatsApp: up to 2m connected users per server
  • Yahoo!: bookmarking service, 5m users and 150m bookmarked URLs


Let's talk about Elixir

  • First released in 2012
  • Superset of the battle-tested Erlang
  • Compiled to bytecode for BEAM
  • Functional
  • Immutable data structures
  • Declarative
  • Dynamic
  • Everything is an expression
  • Processes share nothing by default - they exchange messages (actor model)
  • It stands still faster than Ruby sprints (and eats way less resources)
  • Judging by the syntax it is very Ruby-like but the truth is far from that. Code written in Elixir tends to be more verbose and uses many different concepts.


Somewhat off-topic quiz time!

Imperative vs declarative code

Which way to double this array is imperative and which is declarative?



Which way to double this array is imperative and which is declarative?

a) imperative

b) declarative

Regardless of how I get to your house, what really matters is the car I drive. Am I going to drive

an imperative stick shift car


a declarative automatic car.

- Tyler McGinnis​ 


Now that we know what imperative and declarative really means, let's get back to Elixir :)

Syntax and things I like about the language

so far

Anonymous functions

Inspect stuff

Modules + pattern matching


Modules + pattern matching

Modules + pattern matching

Let's go back to our TestPatternMatching.two_plus_two/1 and add some documentation

We now have documentation in Markdown

Let's add a test file...

Time to write some actual tests?

Nope, we already wrote them :)

The Markdown documentation has actual, runnable tests!

A good way to solve problems with an outdated documentation :)



The pipe operator |>

The task:

  • Generate a list of numbers from 1 to 100
  • Multiply each of these numbers by 2
  • Get the sum of all odd numbers after multiplying them 


The capture operator makes this even sexier :)


Live demo

Where to start


A Drop of Elixir

By Paweł Duda

A Drop of Elixir

  • 1,129