Post on 06-Jul-2015
description
Erlang workshop
Reidar Sollid Erlang workshop in Drammen
2
Erlang
• The world is concurrent • Things in the world don’t share state • Things communicate through messages • Things fail
- Joe Armstrong
Presentation Title - Classification
What is Erlang
3
• Created and maintained by Ericsson (now open source) • Functional, single assignment, strict evaluation, dynamic typing • Actor model, concurrent oriented, fault tolerant, soft-real-time • Light weight processes that communicate using message passing
(You can have several processes in one OS/Java thread) • Erlang started life as modified prolog • Erlang shell, escript and compiled .beam bytecode
Presentation Title - Classification
What problem to solve
4
What is Elixir
5
1) A Ruby like language for the Erlang VM BEAM
2) Seamless Erlang integration: zero-penalty Erlang function calls (and vice versa)
3) Meta programming via macros and a first-class AST (Abstract syntax tree)
4) Polymorphism via protocols inspired by Clojure
Presentation Title - Classification
And this
6
Presentation Title - Classification
Shared memory model
7
Shared memory
Process thread
Process thread
Process thread
Presentation Title - Classification
Message passing
8
Process thread
Process thread
Process thread
Presentation Title - Classification
Concurrency and shared memory model
9
Atoms and variables
10
• An atom is global constant starting with lower case char
• A variable starts with a capital char and is called a variable since it can be bound or unbound. Once the variable is bound it can never change.
Presentation Title - Classification
Pattern matching
11
12
Pattern matching• Everything in Erlang is pattern matching • When assigning a variable, that is really
pattern matching
Loops
13
No while or for loops ?
14
Tail optimised recursion
15
Presentation Title - Classification
Lambdas
16
BIF (Built in Functions)
17
OTP (Open Telecom Platform)
18
1.Mostly used by finance sector, so it just called OTP now 2.Contains a set of behaviours
4.The standard Erlang/OTP behaviours are: 1.gen_server
1. For implementing the server of a client-server relation.
2.gen_fsm 1. For implementing finite state machines.
3.gen_event 1. For implementing event handling functionality.
4.supervisor 1. For implementing a supervisor in a supervision tree.
Rebar
19
20
Rebar
• Rebar is an Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases.
• Contains templates for OTP development
Presentation Title - Classification
Stickers ?
22