Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Elixir - valentine edition
Saša Jurić
February 14, 2017
Programming
0
92
Elixir - valentine edition
Saša Jurić
February 14, 2017
Tweet
Share
More Decks by Saša Jurić
See All by Saša Jurić
sasajuric
0
120
sasajuric
3
380
sasajuric
3
510
sasajuric
3
230
sasajuric
16
1k
sasajuric
2
560
sasajuric
3
740
sasajuric
1
160
sasajuric
0
76
Other Decks in Programming
See All in Programming
saten
1
170
koher
8
1.1k
emmaglorypraise
0
120
vixentael
0
300
legalforce
PRO
0
600
bells17
0
360
grapecity_dev
0
170
grapecity_dev
0
170
rarous
0
170
danilop
0
220
alperhankendi
1
140
grapecity_dev
0
170
Featured
See All Featured
morganepeng
93
14k
scottboms
251
11k
malarkey
192
8.6k
zenorocha
296
40k
notwaldorf
15
1.8k
ammeep
656
54k
edds
56
9.4k
chrislema
231
16k
phodgson
87
3.9k
myddelton
109
11k
kneath
295
39k
roundedbygravity
84
7.8k
Transcript
Elixir @sasajuric aircloak.com
None
None
otpornost na pogreške skalabilnost responzivnost
Erlang LFE Elixir Erlang VM (BEAM)
None
v1 = f1(p1, p2, ...) v2 = f2(...) ...
spawn(fn -> ... end) A B
OS proces BEAM proces
scheduler scheduler scheduler scheduler BEAM instanca CPU CPU CPU CPU
pid = spawn(fn -> ... end)
pid = spawn(fn -> ... end) send(pid, :ping)
spawn(fn -> receive do :ping -> # ... end end)
send(pid, {:ping, self()})
spawn(fn -> receive do {:ping, caller_pid} -> send(caller_pid, :pong) end
end)
send(pid, {:ping, self()}) receive do :pong -> # ... after
:timer.seconds(5) -> # ... end
pid = spawn(fn -> server_loop(state) end)
defp server_loop(state) do receive do message -> new_state = handle(state,
message) server_loop(new_state) end end
bank account balance
send(pid, {:deposit, 100}) send(pid, {:withdraw, 100}) send(pid, {:balance, self()}) receive
do balance -> # ... end
spawn(fn -> bank_account_loop(0) end)
def bank_account_loop(balance) do receive do {:deposit, amount} -> bank_account_loop(balance +
amount) {:withdraw, amount} -> bank_account_loop(balance - amount) {:balance, caller_pid} -> send(caller_pid, balance) bank_account_loop(balance) end end
bank account {:deposit, amount} {:withdraw, amount} :balance
None
db connection background job request handler state request handler request
handler request handler request handler request handler state state state background job background job background job db connection db connection db connection
A B C D E F
A exit notifikacija B C D E F
S S S W W S W W W S
W W
VM VM VM VM VM
VM send(pid, message) VM 1 send(pid, message) VM 2
elixir-lang.org phoenixframework.org adventofcode.com exercism.io elixirforum.com meetup.com/lambdazagreb/