Intro to Erlang*
*and the BEAM
Who am I?
- Erik Nilsen
- enilsen16 on most places
- I tweet about random things

- Work at answerky
- In Brisbane and QUT as part of the Hotdesq program.

What I hope you get from this talk
- Well thought out language
- Being used in interesting ways
- Distributed Computing is cool
- I want to leave you curious :D
What you won't get from this talk
- Deep dive into OTP
- Live coding examples
- Almost every slide in this presentation could be it's own talk.
For more information on any of these topics come talk to me.
The Actor Model
- Individual actors can only modify their own state
- To communicate with other actors they pass messages
- This concept was co-created by Carl Hewitt
So what is Erlang?
Erlang is a general-purpose programming language and runtime environment. Erlang has built-in support for concurrency, distribution and fault tolerance. Erlang is used in several large telecommunication systems from Ericsson.
Cool...
What Does that MEAN?
- Erlang is a functional programming language with a large emphasis on Concurrency and High Reliability.
- Pattern Matching and Immutable data are core features
- Erlang allows for dozens of tasks or processes to preform at the same time. (Actor Model)
- Each process runs separately inside BEAM, the virtual machine.
- Message passing between processes is the only way to interact.
More on Erlangs Processes
- Because each one of these processes is lightweight and isolated, communication is explicit and safe. (Avoid locks)
- You can have millions of processes at once
- You can manage these processes with Supervisors
- These Supervisors monitor and restart processes

Why was it created?
- When you are building systems, you're going to have failures that are out of your control. (Hardware, Network Layer Failures, Etc..)
- Their also may be bugs, that only happen in certain situations. (These can be extremely hard to reproduce.)
- When programming telecom systems or 911 call centers you can't afford for the entire system to go down.
Who created it?
- Ericsson wrote the first version in 1986
- Originally written in Prolog(Hence the syntax)
OTP Overview
| BEAM | Use case |
|---|---|
| Standard Library | Erlang |
| Common Test, Eunit | Testing Frameworks |
| Mnesia | A Database |
| ETS | A key/value store(in memory) |
| Dialyzer | A type checker |
http://erlang.org/doc/applications.html
There's a lot more...
Erlangs ability to work with other languages
- C and C++
- Java
- Ruby
- Rust
- Python
Who Uses Erlang?
- League Of Legends chat system(Riot Games)
- WhatsApp, Whisper, FB Messenger
- Almost all telecom companies
- Adroll(for real time bidding)
- Ericsson(Currently developing 5G)
- Basho Riak, RabbitMQ
- A lot more
A short look at the Erlang Syntax
-module(count_to_ten).
-export([count_to_ten/0]).
count_to_ten() -> do_count(0).
do_count(10) -> 10;
do_count(N) -> do_count(N + 1).Other Languages That Run on BEAM
- Elixir (Ruby Like)
- Lisp flavored Erlang(lfe)
- Alpaca(ML like syntax)
Elixir
- Written by Jose Valim
- Ruby-like syntax
- Popular Libraries around it
- Includes improved tooling
- Modern community
Show me the Numbers

ErLang SYTAX Example
Elixir Sytax Example
-module(count_to_ten).
-export([count_to_ten/0]).
count_to_ten() -> do_count(0).
do_count(10) -> 10;
do_count(N) -> do_count(N + 1).defmodule CountToTen do
def count_to_ten do
do_count(0)
end
defp do_count(10), do: 10
defp do_count(x) do
do_count(x+1)
end
end
Popular Erlang and Elixir Projects
- Nerves
- Phoenix
- QuickCheck
- Riak
How does Erlang Apply to Distributed Computing
Well First why is distributed Computing hard?
I mean this is a mostly solved problem right

*slide from http://bit.ly/2qVavtl
What is the problem?

*slide from http://bit.ly/2qVavtl

*slide from http://bit.ly/2qVavtl

*slide from http://bit.ly/2qVavtl
Well, how is this actually sort of Solved?

With CRDTs...
Projects in Distributed Computing
- Distributed Erlang
- Riak Core
- Erleans
- Lasp
- Loquat
It's an exciting time to be an erlang or Elixir Developer
People To follow in the BEAM Community
- Fred Hubert
- Jose Valim
- James Fish
- Robert Virding(Erlang Co-Creator)
- Joe Armstrong(Erlang Co-Creator)
People to follow in Distributed Computing
- Carl Hewitt
- Christopher Meiklejohn
-
Tristan Sloughter
Where to learn more
- http://learnyousomeerlang.com/
- https://pragprog.com/book/elixir13/programming-elixir-1-3
- https://github.com/h4cc/awesome-elixir
Fin
Intro to Erlang*
By enilsen16
Intro to Erlang*
- 756