0
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 ...
Properties                 Functional programming language, high   Declarative   abstraction level, pattern matching and  ...
Properties                   Simple and consistent error recovery,     Robustness    supervision hierarchies and "program ...
Properties                      "Ports" to the outside world behave asExternal Interfaces                      Erlang proc...
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...
The Erlang Shell3> A = test.test4> B = {“string”, A}.{“string”,test}5> {S, test} = B.{“string”,test}6> S.                 ...
The Erlang Shell7> [72,101,108,108,111,32,87,111,114,108,100]."Hello World"8> [{person, "Joe", "Armstrong"}, {person,"Robe...
Modules & Functions-module(demo).-export([double/1]).% This is a comment.% Everything after % is ignored.double(X) ->    t...
Modules & Functions-module(demo).                              module name-export([double/1]).% This is a comment.% Everyt...
Modules & Functions-module(demo).                              module name-export([double/1]).                         exp...
Modules & Functions-module(demo).                              module name-export([double/1]).                         exp...
Modules & Functions-module(demo).                              module name-export([double/1]).                         exp...
Modules & Functions-module(demo).                              module name-export([double/1]).                         exp...
Modules & Functions9> c(demo).{ok,demo}10> demo:double(21).4211> demo:times(3, 3).** exception error: undefined functiondem...
Processes            © 2011 Erlang Solutions Ltd.
Processes  Pid = spawn(M, F, A)                 © 2011 Erlang Solutions Ltd.
Processes  Pid = spawn(M, F, A)                                                  M:F(A)                                   ...
Processes   Pid = spawn(M, F, A)                                                     M:F(A)  Pid ! {msg, self()}          ...
Processes   Pid = spawn(M, F, A)                                                      M:F(A)  Pid ! {msg, self()}         ...
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    ...
Processes                node@host Application    Application                   Application      1              2         ...
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() =                                 ...
Distribution        cat                                     dog       flea                                      bird      n...
Distribution       cat                                     dog      flea                                      bird         ...
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 t...
A Talking Virus$ erl -name somename -setcookie dyncon...Eshell V5.8.2 (abort with ^G)(somename@somehost)1> nodes().[](some...
Resources       http://tryerlang.orghttp://learnyousomeerlang.com        © 1999-2011 Erlang Solutions Ltd.
Thank you!adam@erlang-solutions.com      @eproxus      © 1999-2011 Erlang Solutions Ltd.
Upcoming SlideShare
Loading in...5
×

Erlang Workshop at Dyncon 2011

1,207

Published on

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.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,207
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
49
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \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
  • Transcript of "Erlang Workshop at Dyncon 2011"

    1. 1. Erlang Solutions Ltd.Erlang Workshop © 1999-2011 Erlang Solutions Ltd.
    2. 2. 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.
    3. 3. 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.
    4. 4. 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.
    5. 5. 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.
    6. 6. Where is Erlang used? © 2011 Erlang Solutions Ltd.
    7. 7. 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.
    8. 8. The Erlang Shell3> A = test.test4> B = {“string”, A}.{“string”,test}5> {S, test} = B.{“string”,test}6> S. © 2011 Erlang Solutions Ltd.
    9. 9. 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.
    10. 10. 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.
    11. 11. 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.
    12. 12. 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.
    13. 13. 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.
    14. 14. 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.
    15. 15. 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.
    16. 16. 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.
    17. 17. Processes © 2011 Erlang Solutions Ltd.
    18. 18. Processes Pid = spawn(M, F, A) © 2011 Erlang Solutions Ltd.
    19. 19. Processes Pid = spawn(M, F, A) M:F(A) receive {msg, From} -> From ! ok end © 2011 Erlang Solutions Ltd.
    20. 20. Processes Pid = spawn(M, F, A) M:F(A) Pid ! {msg, self()} receive {msg, From} -> From ! ok end © 2011 Erlang Solutions Ltd.
    21. 21. Processes Pid = spawn(M, F, A) M:F(A) Pid ! {msg, self()} receive ok {msg, From} -> From ! ok end © 2011 Erlang Solutions Ltd.
    22. 22. Processes © 2011 Erlang Solutions Ltd.
    23. 23. Processes supervisor © 2011 Erlang Solutions Ltd.
    24. 24. Processes supervisor worker © 2011 Erlang Solutions Ltd.
    25. 25. Processes supervisor worker © 2011 Erlang Solutions Ltd.
    26. 26. Processes © 2011 Erlang Solutions Ltd.
    27. 27. Processes Application 1 © 2011 Erlang Solutions Ltd.
    28. 28. Processes Application Application Application 1 2 3 © 2011 Erlang Solutions Ltd.
    29. 29. Processes node@host Application Application Application 1 2 3 © 2011 Erlang Solutions Ltd.
    30. 30. Distribution © 2011 Erlang Solutions Ltd.
    31. 31. Distribution cat nodes() = [] © 2011 Erlang Solutions Ltd.
    32. 32. Distribution cat flea nodes() =[cat@home, flea@home] © 2011 Erlang Solutions Ltd.
    33. 33. Distribution cat dog flea nodes() = nodes() =[cat@home, flea@home] [] © 2011 Erlang Solutions Ltd.
    34. 34. Distribution cat dog flea bird nodes() = nodes() =[cat@home, flea@home] [dog@work, bird@work] © 2011 Erlang Solutions Ltd.
    35. 35. Distribution cat dog flea bird nodes() = [cat@home, flea@home, dog@work, bird@work] © 2011 Erlang Solutions Ltd.
    36. 36. Demo time! © 1999-2011 Erlang Solutions Ltd.
    37. 37. 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.
    38. 38. 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.
    39. 39. Resources http://tryerlang.orghttp://learnyousomeerlang.com © 1999-2011 Erlang Solutions Ltd.
    40. 40. Thank you!adam@erlang-solutions.com @eproxus © 1999-2011 Erlang Solutions Ltd.
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×