SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
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 typing.
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
       Wooga:              Backend for Facebook games
       Klarna:               Electronic payment systems
Functional
      -module(hello).
      -export([world/0]).

      world() ->
         io:format("Hello, world!~n", []).
Let it run!
$ erl
Erlang 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
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 of right
     hand side value "are boring"
Pattern Matching
     > Tuple = { “Erlang”, “Joe A.”}.
     { “Erlang”, “Joe A.”}.

     > { Language, Inventor } = Tuple.
     { “Erlang”, “Joe A.”}.

     > Language.
     “Erlang”
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])
     !    !    !        end,
     !    !    !        ["Geek", "Girl", "Meetup"]
     !    !          ).

     “Geek”
     “Girl”
     “Meetup”
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”, [Content]);
             loop();
          Any ->
             io:format(“Received unexpected: ~p”, [Any])
        end.
Spawning a process
                  PID = spawn(fun loop/0).
        PID ! {message, “GeekGirlMeetup”}.
                     is_process_alive(PID).
                                      true.
                                PID ! stop.
                     is_process_alive(PID).
                                      false.
Monitor processes
            Processes can be monitored.
        EXIT signals with a reason will be
                                 received.

          process_flag(trap_exit, true).
               {‘EXIT’, From, Reason}.
Useful for
      Distributed, reliable, concurrent systems

Más contenido relacionado

Similar a Erlang is not a city in Germany

Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for RubyistsSean Cribbs
 
Introduction To Erlang Final
Introduction To Erlang   FinalIntroduction To Erlang   Final
Introduction To Erlang FinalSinarShebl
 
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...siouxhotornot
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Winl xf
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrongSentifi
 
Erlang bootstrap course
Erlang bootstrap courseErlang bootstrap course
Erlang bootstrap courseMartin Logan
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyiststchandy
 
The Erlang Programming Language
The Erlang Programming LanguageThe Erlang Programming Language
The Erlang Programming LanguageDennis Byrne
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to ElixirDiacode
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 

Similar a Erlang is not a city in Germany (20)

Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for Rubyists
 
Introduction To Erlang Final
Introduction To Erlang   FinalIntroduction To Erlang   Final
Introduction To Erlang Final
 
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
 
Elixir
ElixirElixir
Elixir
 
Erlang intro
Erlang introErlang intro
Erlang intro
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrong
 
Elixir cheatsheet
Elixir cheatsheetElixir cheatsheet
Elixir cheatsheet
 
Python 101 1
Python 101   1Python 101   1
Python 101 1
 
Elixir introduction
Elixir introductionElixir introduction
Elixir introduction
 
Erlang bootstrap course
Erlang bootstrap courseErlang bootstrap course
Erlang bootstrap course
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyists
 
Erlang and Elixir
Erlang and ElixirErlang and Elixir
Erlang and Elixir
 
The Erlang Programming Language
The Erlang Programming LanguageThe Erlang Programming Language
The Erlang Programming Language
 
Erlang, an overview
Erlang, an overviewErlang, an overview
Erlang, an overview
 
Erlang
ErlangErlang
Erlang
 
Erlang in 10 minutes
Erlang in 10 minutesErlang in 10 minutes
Erlang in 10 minutes
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 

Erlang is not a city in Germany

  • 1. Erlang is not a city in Germany!
  • 2. About me Monika Moser @momo13 Software Architect
  • 3. Erlang is a general-purpose language and a runtime environment.
  • 4. Language Functional. Strict evaluation. Single assignment. Dynamic typing.
  • 5. Erlang has built in support for concurrency, distribution and fault tolerance.
  • 6. Ericsson Language since 1986
  • 7. Developed to build near-real-time fault tolerant distributed non-stop applications.
  • 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. Functional -module(hello). -export([world/0]). world() -> io:format("Hello, world!~n", []).
  • 10. Let it run! $ erl Erlang 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. Expressions > % A comment > 1 + 3. 4 > “This is a string”. “This is a string”
  • 12. Expressions > [1, 2, 3]. [1,2,3]. > [72, 101, 108, 108, 111, 33]. “Hello!”
  • 13. Expressions > Variable = “GeekGirls”. “GeekGirls” > Variable = "are boring". ** exception error: no match of right hand side value "are boring"
  • 14. Pattern Matching > Tuple = { “Erlang”, “Joe A.”}. { “Erlang”, “Joe A.”}. > { Language, Inventor } = Tuple. { “Erlang”, “Joe A.”}. > Language. “Erlang”
  • 15. Recursion fac(0) -> 1; fac(N) when N > 0, is_integer(N) -> N*fac(N-1).
  • 16. Higher order functions > lists:foreach(fun(Word) -> ! ! ! ! io:format("~p~n", [Word]) ! ! ! end, ! ! ! ["Geek", "Girl", "Meetup"] ! ! ). “Geek” “Girl” “Meetup”
  • 17. Fun with Lists List comprehension: > [ X*X || X <- [2, 3, 4], X rem 2 == 0]. [4,16]
  • 18. Concurrency Lightweight processes Message passing primitives
  • 19. Sending Messages PID ! { message, “Content”}.
  • 20. Receiving Messages loop() -> receive { message, Content } -> io:format(“Content: ~p”, [Content]); loop(); Any -> io:format(“Received unexpected: ~p”, [Any]) end.
  • 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. Monitor processes Processes can be monitored. EXIT signals with a reason will be received. process_flag(trap_exit, true). {‘EXIT’, From, Reason}.
  • 23. Useful for Distributed, reliable, concurrent systems