Skip to content

Instantly share code, notes, and snippets.

@essen
Last active September 22, 2018 08:35
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save essen/6333394 to your computer and use it in GitHub Desktop.
Save essen/6333394 to your computer and use it in GitHub Desktop.

Thinking in Erlang

One day Erlang training.

Goals

This training should get you started with Erlang and understand how to design a highly available distributed system. Because there is only one day, we focus on the essential concepts and skip over many details that would be covered in the normal three days course.

After learning the basics and doing a few exercises we will start writing a simple chat client and server and improve it as we learn new things.

You are encouraged to help the people around you once you figure things out for yourself.

At the end of this training you should be able to:

  • Install Erlang
  • Have basic knowledge of the Erlang language
  • Understand concurrency and message passing
  • Learn how to handle errors
  • Understand how to build highly available systems
  • Recognize Joe Armstrong, Robert Virding and Mike Williams

Requirements

  • Your own laptop
  • Erlang R16B02:
  • Wi-Fi connection for installing Erlang during the training
  • Otherwise, read below if you wish to install Erlang beforehand

Programme

Erlang Installation

20 minutes, Wi-Fi required

If you can, please come with Erlang R16B02 already installed on your machine. Please use the ESL packages. Arch Linux users can use the pacman package directly.

If everyone comes with Erlang installed we can move through this part quicker.

  • Install Erlang
  • Watch Erlang the Movie while it downloads/installs
  • Start and stop the shell (Ctrl+C and Ctrl+G)
  • io:format("Hello world!")

Overview of an Erlang system

20 minutes

Get a first look at modules, applications, processes and supervision trees.

  • erlang:loaded()
  • application:loaded_applications()
  • i()
  • observer:start()
  • Diagram summarizing a distributed Erlang system

Basic syntax and types

60 minutes

We will cover the following types which are necessary to follow the training, and skip the few types we won't need.

  • integer
  • atom
  • list
  • tuple
  • pid
  • reference
  • fun

We will cover the following syntax.

  • Module
  • Function definition
  • Function clauses
  • Guards
  • Pattern matching in function clauses
  • Exports
  • Local function calls
  • Remote function calls
  • Case .. of
  • Pattern matching with =

Recursion

40 minutes

We will cover the following recursion concepts:

  • Recursing through a list
  • Accumulator
  • Map
  • Program loop

Concurrency and message passing

120 minutes

What makes Erlang so special.

  • Overview of processes
  • Spawn
  • Order of execution is undefined
  • Processes are cheap
  • Processes are isolated
  • Message passing
  • Receive
  • Receive .. after
  • Selective receive
  • Server processes
  • RPC
  • Process registry

Remote error handling

60 minutes

First taste of high availability.

  • Monitors
  • Safe RPC
  • Links
  • What to do when processes crash?
  • Supervisor
  • Supervision trees

Quick look at distribution

30 minutes

Connect nodes, make them speak together.

  • Nodes
  • Node names
  • Connecting nodes
  • Global process registry

Highly available systems

30 minutes

Everything you need to know before you can build a highly available system. These apply to any system, not just ones written in Erlang.

  • Isolation
  • Concurrency
  • Error detection
  • Error identification
  • Live upgrades
  • Stable storage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment