Skip to the content.


Language that runs on top of the Erlang VM.

Install on Ubuntu

# install Erlang
wget && sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt update
sudo apt install esl-erlang

# install Elixir
sudo apt install elixir

Basic Usage

File Types

Elixir treats both files exactly the same way, the only difference is in intention. .ex files are meant to be compiled while .exs files are used for scripting. When executed, both extensions compile and load their modules into memory, although only .ex files write their bytecode to disk in the format of .beam files. [Scripted mode]


Stdout and Stdin

Basic Types


[Elixir - Binaries, strings, and charlists]

Regular Expressions

Everything that starts with ~ are sigils

sigils are one of the mechanisms provided by the language for working with textual representations. Sigils start with the tilde (~) character which is followed by a letter (which identifies the sigil) and then a delimiter; optionally, modifiers can be added after the final delimiter. [Sigils]

Modules and Functions

defModule macro

Use the defModule macro to define a module grouping multiple functions - demo in demos/Math.exs

# Call with elixir demos/Math.exs 1 2
defmodule Math do
  def sum(a, b) do
    a + b

  def sum([a, b]) do
    sum a, b

|> Math.sum
|> IO.puts
def and defp macros