Erlang Workshop at Dyncon 2011
Upcoming SlideShare
Loading in...5
×
 

Erlang Workshop at Dyncon 2011

on

  • 1,392 views

In this session you'll become familiar with the basic syntax of Erlang, learn how to write programs and experience the central concepts of the language: functional programming, concurrency, fault ...

In this session you'll become familiar with the basic syntax of Erlang, learn how to write programs and experience the central concepts of the language: functional programming, concurrency, fault tolerance and distribution. You will get familiar with the Erlang shell and basic Erlang programs, try concurrent programming by using message passing and get a taste of Erlang distribution.

Statistics

Views

Total Views
1,392
Views on SlideShare
1,353
Embed Views
39

Actions

Likes
3
Downloads
42
Comments
0

2 Embeds 39

http://speakerrate.com 36
http://www.linkedin.com 3

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • Facebook (Chat), Amazon (SimpleDB), Klarna (E-Commerce billing), T-Mobile (SMS gateway), Yahoo! (Delicious), GitHub (RPC and Messaging), RabbitMQ (Enterprise messaging), CouchDB (NoSQL), Riak (NoSQL)\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Erlang Workshop at Dyncon 2011 Erlang Workshop at Dyncon 2011 Presentation Transcript

  • Erlang Solutions Ltd.Erlang Workshop © 1999-2011 Erlang Solutions Ltd.
  • Erlang, the Language• Started out in the Ericsson software lab 1987 (!)• Released as open source in 1998• Gains Symmetric Multi Processing (SMP) support in 2005 2000000 1500000 1000000 Requests/Month 500000 0 1998 2001 2003 2005 2007 2009 © 2011 Erlang Solutions Ltd.
  • Properties Functional programming language, high Declarative abstraction level, pattern matching and concise readable programs Either transparent or explicit concurrency, Concurrency light-weight processes and highly scalable Response times in the order of millisecondsSoft Real-Time per-process garbage collection © 2011 Erlang Solutions Ltd. View slide
  • Properties Simple and consistent error recovery, Robustness supervision hierarchies and "program for the correct case" Explicit or transparent distribution Distribution Network-aware runtime system Easily change code in a running system.Hot code loading Enables non-stop operation Simplifies testing © 2011 Erlang Solutions Ltd. View slide
  • Properties "Ports" to the outside world behave asExternal Interfaces Erlang processes Erlang runs on any UNIX, Windows, Portability VxWorks. Supports heterogeneous networks Symmetric multiprocessing support. Takes SMP Support full advantage of multiple CPU architectures © 2011 Erlang Solutions Ltd.
  • Where is Erlang used? © 2011 Erlang Solutions Ltd.
  • The Erlang Shell$ erlErlang R14B01 (erts-5.8.2) [...]Eshell V5.8.2 (abort with ^G)1> 2 + 3.52> [1, 2, 3] ++ [4, 5, 6].[1,2,3,4,5,6] © 2011 Erlang Solutions Ltd.
  • The Erlang Shell3> A = test.test4> B = {“string”, A}.{“string”,test}5> {S, test} = B.{“string”,test}6> S. © 2011 Erlang Solutions Ltd.
  • The Erlang Shell7> [72,101,108,108,111,32,87,111,114,108,100]."Hello World"8> [{person, "Joe", "Armstrong"}, {person,"Robert", "Virding"}, {person, "Mike","Williams"}].[{person, "Joe", "Armstrong"}, {person, "Robert", "Virding"}, {person, "Mike", "Williams"}] © 2011 Erlang Solutions Ltd.
  • Modules & Functions-module(demo).-export([double/1]).% This is a comment.% Everything after % is ignored.double(X) ->    times(X, 2).times(X, N) ->    X * N. https://gist.github.com/854366 © 2011 Erlang Solutions Ltd.
  • Modules & Functions-module(demo). module name-export([double/1]).% This is a comment.% Everything after % is ignored.double(X) ->    times(X, 2).times(X, N) ->    X * N. https://gist.github.com/854366 © 2011 Erlang Solutions Ltd.
  • Modules & Functions-module(demo). module name-export([double/1]). exported functions% This is a comment.% Everything after % is ignored.double(X) ->    times(X, 2).times(X, N) ->    X * N. https://gist.github.com/854366 © 2011 Erlang Solutions Ltd.
  • Modules & Functions-module(demo). module name-export([double/1]). exported functions comment% This is a comment.% Everything after % is ignored.double(X) ->    times(X, 2).times(X, N) ->    X * N. https://gist.github.com/854366 © 2011 Erlang Solutions Ltd.
  • Modules & Functions-module(demo). module name-export([double/1]). exported functions comment% This is a comment.% Everything after % is ignored.double(X) -> function    times(X, 2).times(X, N) ->    X * N. https://gist.github.com/854366 © 2011 Erlang Solutions Ltd.
  • Modules & Functions-module(demo). module name-export([double/1]). exported functions comment% This is a comment.% Everything after % is ignored.double(X) -> function    times(X, 2).times(X, N) -> last expression is the    X * N. return value https://gist.github.com/854366 © 2011 Erlang Solutions Ltd.
  • Modules & Functions9> c(demo).{ok,demo}10> demo:double(21).4211> demo:times(3, 3).** exception error: undefined functiondemo:times/2 © 2011 Erlang Solutions Ltd.
  • Processes © 2011 Erlang Solutions Ltd.
  • Processes Pid = spawn(M, F, A) © 2011 Erlang Solutions Ltd.
  • Processes Pid = spawn(M, F, A) M:F(A) receive {msg, From} -> From ! ok end © 2011 Erlang Solutions Ltd.
  • Processes Pid = spawn(M, F, A) M:F(A) Pid ! {msg, self()} receive {msg, From} -> From ! ok end © 2011 Erlang Solutions Ltd.
  • Processes Pid = spawn(M, F, A) M:F(A) Pid ! {msg, self()} receive ok {msg, From} -> From ! ok end © 2011 Erlang Solutions Ltd.
  • Processes © 2011 Erlang Solutions Ltd.
  • Processes supervisor © 2011 Erlang Solutions Ltd.
  • Processes supervisor worker © 2011 Erlang Solutions Ltd.
  • Processes supervisor worker © 2011 Erlang Solutions Ltd.
  • Processes © 2011 Erlang Solutions Ltd.
  • Processes Application 1 © 2011 Erlang Solutions Ltd.
  • Processes Application Application Application 1 2 3 © 2011 Erlang Solutions Ltd.
  • Processes node@host Application Application Application 1 2 3 © 2011 Erlang Solutions Ltd.
  • Distribution © 2011 Erlang Solutions Ltd.
  • Distribution cat nodes() = [] © 2011 Erlang Solutions Ltd.
  • Distribution cat flea nodes() =[cat@home, flea@home] © 2011 Erlang Solutions Ltd.
  • Distribution cat dog flea nodes() = nodes() =[cat@home, flea@home] [] © 2011 Erlang Solutions Ltd.
  • Distribution cat dog flea bird nodes() = nodes() =[cat@home, flea@home] [dog@work, bird@work] © 2011 Erlang Solutions Ltd.
  • Distribution cat dog flea bird nodes() = [cat@home, flea@home, dog@work, bird@work] © 2011 Erlang Solutions Ltd.
  • Demo time! © 1999-2011 Erlang Solutions Ltd.
  • A Talking Virus • A module that starts a process • When that process detects a new node in the cluster - It will copy the module to that node - And start a new process on that node - Which will do the same to connecting nodes • Source code: https://gist.github.com/854389 © 2011 Erlang Solutions Ltd.
  • A Talking Virus$ erl -name somename -setcookie dyncon...Eshell V5.8.2 (abort with ^G)(somename@somehost)1> nodes().[](somename@somehost)2> net_adm:ping(adam@192.168.161.166).pong © 2011 Erlang Solutions Ltd.
  • Resources http://tryerlang.orghttp://learnyousomeerlang.com © 1999-2011 Erlang Solutions Ltd.
  • Thank you!adam@erlang-solutions.com @eproxus © 1999-2011 Erlang Solutions Ltd.