Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Erlang         is not a city in Germany!
About me           Monika Moser               @momo13           Software Architect
Erlang         is a general-purpose language and                   a runtime environment.
Language                   Functional.            Strict evaluation.           Single assignment.             Dynamic typi...
Erlang         has built in support for concurrency,              distribution and fault tolerance.
Ericsson Language                    since 1986
Developed       to build near-real-time fault tolerant          distributed non-stop applications.
Used by     CouchDB:    NoSQL DB that uses JSON to store data     Facebook:                     For the chat backend      ...
Functional      -module(hello).      -export([world/0]).      world() ->         io:format("Hello, world!~n", []).
Let it run!$ erlErlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:2:2] [async-threads:0] [hipe][kernel-poll:false]Eshell V...
Expressions     > % A comment     > 1 + 3.     4     > “This is a string”.     “This is a string”
Expressions     > [1, 2, 3].     [1,2,3].     > [72, 101, 108, 108, 111, 33].     “Hello!”
Expressions     > Variable = “GeekGirls”.     “GeekGirls”     > Variable = "are boring".     ** exception error: no match ...
Pattern Matching     > Tuple = { “Erlang”, “Joe A.”}.     { “Erlang”, “Joe A.”}.     > { Language, Inventor } = Tuple.    ...
Recursion     fac(0) ->        1;     fac(N) when N > 0, is_integer(N) ->        N*fac(N-1).
Higher order functions     > lists:foreach(fun(Word) ->     !    !    !   !       io:format("~p~n", [Word])     !    !    ...
Fun with Lists      List comprehension:      > [ X*X || X <- [2, 3, 4], X rem 2 == 0].      [4,16]
Concurrency             Lightweight processes          Message passing primitives
Sending Messages          PID ! { message, “Content”}.
Receiving Messages     loop() ->        receive          { message, Content } ->             io:format(“Content: ~p”, [Con...
Spawning a process                  PID = spawn(fun loop/0).        PID ! {message, “GeekGirlMeetup”}.                    ...
Monitor processes            Processes can be monitored.        EXIT signals with a reason will be                        ...
Useful for      Distributed, reliable, concurrent systems
Upcoming SlideShare
Loading in …5
×

Erlang is not a city in Germany

1,684 views

Published on

Short introduction to the programming language Erlang hold at the GeekGirlMeetup in Berlin 2012

  • Be the first to comment

Erlang is not a city in Germany

  1. 1. Erlang is not a city in Germany!
  2. 2. About me Monika Moser @momo13 Software Architect
  3. 3. Erlang is a general-purpose language and a runtime environment.
  4. 4. Language Functional. Strict evaluation. Single assignment. Dynamic typing.
  5. 5. Erlang has built in support for concurrency, distribution and fault tolerance.
  6. 6. Ericsson Language since 1986
  7. 7. Developed to build near-real-time fault tolerant distributed non-stop applications.
  8. 8. Used by CouchDB: NoSQL DB that uses JSON to store data Facebook: For the chat backend Wooga: Backend for Facebook games Klarna: Electronic payment systems
  9. 9. Functional -module(hello). -export([world/0]). world() -> io:format("Hello, world!~n", []).
  10. 10. Let it run!$ erlErlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:2:2] [async-threads:0] [hipe][kernel-poll:false]Eshell V5.9.1 (abort with ^G)1> c(hello).{ok,hello}2> hello:world().Hello, world!ok
  11. 11. Expressions > % A comment > 1 + 3. 4 > “This is a string”. “This is a string”
  12. 12. Expressions > [1, 2, 3]. [1,2,3]. > [72, 101, 108, 108, 111, 33]. “Hello!”
  13. 13. Expressions > Variable = “GeekGirls”. “GeekGirls” > Variable = "are boring". ** exception error: no match of right hand side value "are boring"
  14. 14. Pattern Matching > Tuple = { “Erlang”, “Joe A.”}. { “Erlang”, “Joe A.”}. > { Language, Inventor } = Tuple. { “Erlang”, “Joe A.”}. > Language. “Erlang”
  15. 15. Recursion fac(0) -> 1; fac(N) when N > 0, is_integer(N) -> N*fac(N-1).
  16. 16. Higher order functions > lists:foreach(fun(Word) -> ! ! ! ! io:format("~p~n", [Word]) ! ! ! end, ! ! ! ["Geek", "Girl", "Meetup"] ! ! ). “Geek” “Girl” “Meetup”
  17. 17. Fun with Lists List comprehension: > [ X*X || X <- [2, 3, 4], X rem 2 == 0]. [4,16]
  18. 18. Concurrency Lightweight processes Message passing primitives
  19. 19. Sending Messages PID ! { message, “Content”}.
  20. 20. Receiving Messages loop() -> receive { message, Content } -> io:format(“Content: ~p”, [Content]); loop(); Any -> io:format(“Received unexpected: ~p”, [Any]) end.
  21. 21. Spawning a process PID = spawn(fun loop/0). PID ! {message, “GeekGirlMeetup”}. is_process_alive(PID). true. PID ! stop. is_process_alive(PID). false.
  22. 22. Monitor processes Processes can be monitored. EXIT signals with a reason will be received. process_flag(trap_exit, true). {‘EXIT’, From, Reason}.
  23. 23. Useful for Distributed, reliable, concurrent systems

×