erlang workshopdrammen

22
Erlang workshop Reidar Sollid Erlang workshop in Drammen

Upload: reidar-sollid

Post on 06-Jul-2015

138 views

Category:

Software


2 download

DESCRIPTION

Erlang workshop for Drammen Software meetup

TRANSCRIPT

Page 1: Erlang workshopdrammen

Erlang workshop

Reidar Sollid Erlang workshop in Drammen

Page 2: Erlang workshopdrammen

2

Erlang

• The world is concurrent • Things in the world don’t share state • Things communicate through messages • Things fail

- Joe Armstrong

Page 3: Erlang workshopdrammen

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

Page 4: Erlang workshopdrammen

Presentation Title - Classification

What problem to solve

4

Page 5: Erlang workshopdrammen

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

Page 6: Erlang workshopdrammen

Presentation Title - Classification

And this

6

Page 7: Erlang workshopdrammen

Presentation Title - Classification

Shared memory model

7

Shared memory

Process thread

Process thread

Process thread

Page 8: Erlang workshopdrammen

Presentation Title - Classification

Message passing

8

Process thread

Process thread

Process thread

Page 9: Erlang workshopdrammen

Presentation Title - Classification

Concurrency and shared memory model

9

Page 10: Erlang workshopdrammen

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.

Page 11: Erlang workshopdrammen

Presentation Title - Classification

Pattern matching

11

Page 12: Erlang workshopdrammen

12

Pattern matching• Everything in Erlang is pattern matching • When assigning a variable, that is really

pattern matching

Page 13: Erlang workshopdrammen

Loops

13

Page 14: Erlang workshopdrammen

No while or for loops ?

14

Page 15: Erlang workshopdrammen

Tail optimised recursion

15

Page 16: Erlang workshopdrammen

Presentation Title - Classification

Lambdas

16

Page 17: Erlang workshopdrammen

BIF (Built in Functions)

17

Page 18: Erlang workshopdrammen

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.

Page 19: Erlang workshopdrammen

Rebar

19

Page 20: Erlang workshopdrammen

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

Page 21: Erlang workshopdrammen

21

Learn you some Erlang

http://learnyousomeerlang.com/

Page 22: Erlang workshopdrammen

Presentation Title - Classification

Stickers ?

22