Thinking in Erlang

One day Erlang training

Loïc Hoguin - @lhoguin

Erlang Cowboy and Nine Nines Founder

Erlang installation

Where to find Erlang

Installing

Where to find help

Erlang the Movie

The shell

Hello world

What's Erlang?

The question

Black boxes

Erlang black boxes

Concurrent programming language

Concurrency?

Modeling the real world

Black boxes fail

Fault detection

Fault identification

Let it crash

Software evolves

Erlang in 6 key points

What's OTP?

OTP

OTP provides middlewares

OTP provides tools

Overview of an Erlang system

Release

Nodes

Nodes (distributed mode)

Processes

Registered processes

Ets tables

Applications

Modules

GUI

The building blocks

Code and data

Sounds familiar?

Code

Releases

Applications 1

Modules

Functions

Data

Nodes

Application 2

Processes

Process registry

Ets tables

Exercise 1

Exercise 2

Types

Integer

Atom 1

Atom 2

List 1

List 2

List 3

List 4

Tuple

Map

Pid

Reference

Fun

Type identification

Other types

Modules and functions

Structure of a module

Exports

Function definition

Guards

Where can guards be used?

Pattern matching in function clauses

Function clauses

case .. of

Local function call

Remote function call

Pattern matching with =

Expressions

Function return value

Recursion

Recursion explained

Recursing through a list

Transforming a list 1

Accumulator

Transforming a list 2

Exercise 3

Transforming a list 3

Transforming a list 4

Exercise 4

Exercise 5

Concurrency and message passing

Exercise 6

Spawn

Order of execution is undefined

Processes are cheap

Processes are isolated

Message passing

receive 1

receive 2

receive 3

receive .. after 1

receive .. after 2

receive .. after 3

receive .. after 4

receive .. after 5

receive .. after 6

Selective receive

Receive loop 1

Receive loop 2

Exercise 7

Process state

Exercise 8

In the previous episode

Cast

Call

Process registry

Remote error handling

Unexpected consequences

Monitors 1

Monitors 2

Exercise 9

Is that really necessary?

Exercise 10

Safe RPC

Links 1

Links 2

Links 3

Links 4

Links 5

Links 6

Links 7

Monitors vs links

Manage the unexpected

Exercise 11

Exercise 12

Supervision tree

Food for thoughts

Final exercise

Erlang chat

Questions