SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
@alepoletto
What is/ Why?
•   Functional programming language.
•   Large emphasis on concurrency and high reliability
•   Erlang's runtime system has built-in support for concurrency,
    distribution and fault tolerance
•   Use the Actor Model
•   Used in telecoms, banking, e-commerce, computer telephony and
    instant messaging.
•   Runs inside a virtual machine.




                                          @alepoletto
Who created?




    @alepoletto
Reference to A. K. Erlang




           @alepoletto
Who is using




    @alepoletto
@alepoletto
Variables and Atoms
•   X = 2 + 2.
•   X = 4.
•   X = 7.
•   x = 4.     (can’t be lower case)


•   Lower case is reserved to atoms
•   Lets say that car is a atom.
•   Them car is a car nothing more.
•   Useful to express values

                             @alepoletto
Functions
soma(A, B) -> A+B.

ola() -> io:format(“Ola”).

olaSoma(A) -> ola(), soma(A,1).




                       @alepoletto
Modules
-module(society).
-export([soma/2]).
-compile(export_all).

soma(A, B) -> A+B.
ola() -> io:format(“Ola”).



                        @alepoletto
Pattern Matcher




      @alepoletto
Pattern Matching
function jovem(Pessoa)
  if Pessoa == chaves then
      print(“Jovem ainda”)
  else if Pessoa == madruga then
      print(“Velho”)
  else
      print(“Não sei")
end

                     @alepoletto
Pattern Matching
jovem(chaves) -> io:format(“Jovem ainda”);
jovem(madruga) -> io:format(“Velho”);
jovem(_) -> io:format(“Não Sei”).

adulto(X) when X >= 21 -> true;
adulto(_) -> false.



                     @alepoletto
Lets be Functional
fatorial(0) -> 1;
fatorial(N) -> when N > 0 -> N * fatorial(N-1).

map(_, []) -> [];
map(F, [H|T]) -> [F(H)|map(F,T)].
L = [1,2,3,4,5].
map(fun society:fatorial/1, L).
map(fun(X) -> X + 1 end, L).

                       @alepoletto
Actors




 @alepoletto
Actors
cobra() ->
  receive
      {From, speak} ->
            From ! “You're the disease, and I'm the
  cure.";
      {From, deal} ->
            From ! “I don't deal with psychos. I put them
  away. ";
      _ ->
            io:format(“no talk")
  end.

                         @alepoletto
Actors
Stallone = spawn(society, cobra, []).
<0.55.0>
Stallone! {self(), speak}.
flush().
"You're the disease, and I'm the cure. “
Stallone! {self(), danca}.
flush().

                      @alepoletto
Actors
cobra() ->
   receive
         {From, speak} ->
                 From ! “You're the disease, and I'm the cure."
                 cobra();
         {From, deal} ->
                 From ! “I don't deal with psychos. I put them away. "
                  cobra();
         _ ->
                 io:format(“no talk")
                 cobra();
   end.


                                @alepoletto
Actors
Stallone! {self(), speak}.
“You're the disease, and I'm the cure.“
 Stallone! {self(), deal}.
“I don't deal with psychos. I put them away. “
Stallone! {self(), shoot}.
“no talk”



                      @alepoletto
Reference
•   http://learnyousomeerlang.com/
•   http://www.erlang.org/
•   http://en.wikipedia.org/wiki/Erlang_(programming_language)




                                   @alepoletto
Thank You




   @alepoletto

Más contenido relacionado

Más de Alexandre Poletto (6)

Node jslt
Node jsltNode jslt
Node jslt
 
LDC 5
LDC 5LDC 5
LDC 5
 
Lt hiccup
Lt hiccupLt hiccup
Lt hiccup
 
Qi4j
Qi4j Qi4j
Qi4j
 
Clojure - LDC
Clojure - LDCClojure - LDC
Clojure - LDC
 
Tecnologias
TecnologiasTecnologias
Tecnologias
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 

Erlang

  • 2. What is/ Why? • Functional programming language. • Large emphasis on concurrency and high reliability • Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance • Use the Actor Model • Used in telecoms, banking, e-commerce, computer telephony and instant messaging. • Runs inside a virtual machine. @alepoletto
  • 3. Who created? @alepoletto
  • 4. Reference to A. K. Erlang @alepoletto
  • 5. Who is using @alepoletto
  • 7. Variables and Atoms • X = 2 + 2. • X = 4. • X = 7. • x = 4. (can’t be lower case) • Lower case is reserved to atoms • Lets say that car is a atom. • Them car is a car nothing more. • Useful to express values @alepoletto
  • 8. Functions soma(A, B) -> A+B. ola() -> io:format(“Ola”). olaSoma(A) -> ola(), soma(A,1). @alepoletto
  • 10. Pattern Matcher @alepoletto
  • 11. Pattern Matching function jovem(Pessoa) if Pessoa == chaves then print(“Jovem ainda”) else if Pessoa == madruga then print(“Velho”) else print(“Não sei") end @alepoletto
  • 12. Pattern Matching jovem(chaves) -> io:format(“Jovem ainda”); jovem(madruga) -> io:format(“Velho”); jovem(_) -> io:format(“Não Sei”). adulto(X) when X >= 21 -> true; adulto(_) -> false. @alepoletto
  • 13. Lets be Functional fatorial(0) -> 1; fatorial(N) -> when N > 0 -> N * fatorial(N-1). map(_, []) -> []; map(F, [H|T]) -> [F(H)|map(F,T)]. L = [1,2,3,4,5]. map(fun society:fatorial/1, L). map(fun(X) -> X + 1 end, L). @alepoletto
  • 15. Actors cobra() -> receive {From, speak} -> From ! “You're the disease, and I'm the cure."; {From, deal} -> From ! “I don't deal with psychos. I put them away. "; _ -> io:format(“no talk") end. @alepoletto
  • 16. Actors Stallone = spawn(society, cobra, []). <0.55.0> Stallone! {self(), speak}. flush(). "You're the disease, and I'm the cure. “ Stallone! {self(), danca}. flush(). @alepoletto
  • 17. Actors cobra() -> receive {From, speak} -> From ! “You're the disease, and I'm the cure." cobra(); {From, deal} -> From ! “I don't deal with psychos. I put them away. " cobra(); _ -> io:format(“no talk") cobra(); end. @alepoletto
  • 18. Actors Stallone! {self(), speak}. “You're the disease, and I'm the cure.“ Stallone! {self(), deal}. “I don't deal with psychos. I put them away. “ Stallone! {self(), shoot}. “no talk” @alepoletto
  • 19. Reference • http://learnyousomeerlang.com/ • http://www.erlang.org/ • http://en.wikipedia.org/wiki/Erlang_(programming_language) @alepoletto
  • 20. Thank You @alepoletto