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
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
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
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