$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ฒߦॲཧ
Ͳ͏͍͏͜ͱʁ
An erlang web server will spawn a single process per
connection - each process is in itself a complete little web
server - if you are running mochiweb with 100K chat sessions
you really have 100K web servers on your machine - not one.
If one of these web servers crashes who cares.
+PF"SNTUSPOH
(http://j.mp/mfpkYo)
Slide 94
Slide 94 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ฒߦॲཧ
Ͳ͏͍͏͜ͱʁ
An erlang web server will spawn a single process per
connection - each process is in itself a complete little web
server - if you are running mochiweb with 100K chat sessions
you really have 100K web servers on your machine - not one.
If one of these web servers crashes who cares.
+PF"SNTUSPOH
(http://j.mp/mfpkYo)
ߨٛϊʔτ
ɹ+PF"SNTUSPOH&SMBOH։ൃऀͷҰਓ
ɹϝʔϦϯάϦετͷલޙͷจ຺͕໘ന͍ͨΊ
ͥͻ
ݪจΛࢀর͠
ͯ΄͍͠ຊޠͰ͋ΕLVFOJTIJ͞Μͷهࣄ͕ৄ͍͠
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
&MJYJS͋·Γ७ਮͰͳ͍
for n <- 1..3 do
end
܁Γฦ͠
͘͠
ݟ͔͚͍ͤͯΔʜ
Slide 220
Slide 220 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
&MJYJS͋·Γ७ਮͰͳ͍
for n <- 1..3 do
if n == 2 do
end
end
܁Γฦ͠
݅ذ
͘͠
ݟ͔͚͍ͤͯΔʜ
Slide 221
Slide 221 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
&MJYJS͋·Γ७ਮͰͳ͍
try do
for n <- 1..3 do
if n == 2 do
throw :break
end
end
catch
:break -> :ok
end
܁Γฦ͠
݅ذ
ྫ֎
͘͠
ݟ͔͚͍ͤͯΔʜ
Slide 222
Slide 222 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
&MJYJS͋·Γ७ਮͰͳ͍
try do
for n <- 1..3 do
if n == 2 do
throw :break
end
IO.puts "number is #{n}”
end
catch
:break -> :ok
end
܁Γฦ͠
݅ذ
ྫ֎
ೖग़ྗ
͘͠
ݟ͔͚͍ͤͯΔʜ
Slide 223
Slide 223 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
&MJYJS͋·Γ७ਮͰͳ͍
try do
for n <- 1..3 do
if n == 2 do
throw :break
end
IO.puts "number is #{n}”
end
catch
:break -> :ok
end
܁Γฦ͠
݅ذ
ྫ֎
ೖग़ྗ
˞ඇਪͳॻ͖ํ
͘͠
ݟ͔͚͍ͤͯΔʜ
Slide 224
Slide 224 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
&MJYJS͋·Γ७ਮͰͳ͍
try do
for n <- 1..3 do
if n == 2 do
throw :break
end
IO.puts "number is #{n}”
end
catch
:break -> :ok
end
܁Γฦ͠
݅ذ
ྫ֎
ೖग़ྗ
˞ඇਪͳॻ͖ํ
͘͠
ݟ͔͚͍ͤͯΔʜ
ߨٛϊʔτ
ɹ܁Γฦ͠
݅ذ
ྫ֎ॲཧͳͲΛ༻͍ͯίʔυ͕هड़Ͱ͖Δ
ɹͨͩ͠
͜ΕΒΛෳࡶʹΈ߹ΘͤΔͷͰ
ैདྷͷଞͷݴޠͱ
ԿมΘΒͳ͍&MJYJSͷֶशΛਐΊΔʹै͍
ΑΓ͔Γ͘͢
؆ܿʹίʔυΛهड़Ͱ͖ΔΑ͏ʹͳΔ
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
Slide 259
Slide 259 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
Slide 260
Slide 260 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
Ұप
O
UBJM
Slide 261
Slide 261 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
Ұप
O
UBJM
ೋप
O
UBJM
Slide 262
Slide 262 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
ࡾप
O
UBJM
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
Slide 263
Slide 263 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
ࡾप
O
UBJM
࢛प
<>
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
Slide 264
Slide 264 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
Ϧετ
ࡾप
O
UBJM
࢛प
<>
defmodule Test do
def puts([]) do
IO.puts("finish")
end
def puts([n | tail]) do
IO.puts("number is #{n}")
puts(tail)
end
end
Test.puts([1, 2, 3])
ߨٛϊʔτ
ɹ͜ͷ࠶ؼͷྫΛ
͜ͷઆ໌͚ͩͰཧղͰ͖ͳ͘ͱΑ͍
ɹ͜ͷิઆ໌Λͱʹ
ϓϩάϥϛϯά&MJYJSͷϦετͱ࠶ؼͷ
߲ΛಡΉͱ
ཧղ͍͢͠
ɹϓϩάϥϛϯά&MJYJSͱ͜ͷઆ໌Λ
͍ͬͨΓ͖ͨΓͰཧղ͢Δ
Slide 265
Slide 265 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
ϓϩάϥϛϯά&MJYJS ΛಡΉલʹʜ
Ϧετ
&OVN
ύΠϓϥΠϯ
EP
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
defmodule Test do
def test do
a = 1
b =
if :true do
a = 2
a
end
{a, b}
end
end
{1, 2} = Test.test
EP
Slide 299
Slide 299 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
defmodule Test do
def test do
a = 1
b =
if :true do
a = 2
a
end
{a, b}
end
end
{1, 2} = Test.test
EP
EFGͷείʔϓ
Slide 300
Slide 300 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
defmodule Test do
def test do
a = 1
b =
if :true do
a = 2
a
end
{a, b}
end
end
{1, 2} = Test.test
EP
JGͷΓ
EFGͷείʔϓ
Slide 301
Slide 301 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
defmodule Test do
def test do
a = 1
b =
if :true do
a = 2
a
end
{a, b}
end
end
{1, 2} = Test.test
EP
JGͷείʔϓ
JGͷΓ
EFGͷείʔϓ
Slide 302
Slide 302 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
defmodule Test do
def test do
a = 1
b =
if :true do
a = 2
a
end
{a, b}
end
end
{1, 2} = Test.test
EP
JGͷΓ
JGͷείʔϓ
B
C
EFGͷείʔϓ
Slide 303
Slide 303 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔܕ
defmodule Test do
def test do
a = 1
b =
if :true do
a = 2
a
end
{a, b}
end
end
{1, 2} = Test.test
EP
JGͷείʔϓ
B
C
ߨٛϊʔτ
ɹϒϩοΫʹείʔϓͱΓ͕͋ΔͨΊ
ϒϩοΫωετͷਂ͍ͱ
͜ΖͰ
্ҐϒϩοΫͷมΛ࠶ଋറ ͢Δඞཁ͕ͳ͍cͰ͖ͳ͍
ɹΑͬͯʮ͜ͷ
Ͳ͔͜Βདྷͨͷ͔ʁʯΛௐΔख͕ؒݮΓ
Մ
ಡੑ্͕͕Δ
JGͷΓ
EFGͷείʔϓ
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
It is really common for OO developers to think of Elixir
modules as the minimal code structure (and therefore
breaking everything into modules) and forget about functions.
+PTÉ7BMJN
(https://groups.google.com/forum/m/#!topic/elixir-lang-talk/Ib11890jfmY)
ؔܕͱ00
ࠞઢ͢Δؔܕͱ00
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔΛ·ͱΊΔ
ߏମܕΛఆٛ͢Δ
ࠞઢ͢Δؔܕͱ00
ؔܕͱ00
Ϟδϡʔϧͷͭͷׂ
defmodule User do
defstruct name: nil, age: nil
def new(name, age) do
%User{name: name, age: age}
end
def puts_name(%User{name: name}) do
IO.puts name
end
end
Slide 364
Slide 364 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔΛ·ͱΊΔ
ߏମܕΛఆٛ͢Δ
ࠞઢ͢Δؔܕͱ00
ؔܕͱ00
Ϟδϡʔϧͷͭͷׂ
defmodule User do
defstruct name: nil, age: nil
def new(name, age) do
%User{name: name, age: age}
end
def puts_name(%User{name: name}) do
IO.puts name
end
end
Ϋϥεఆٛ
ʹݟ͑Δ
Slide 365
Slide 365 text
$PQZSJHIU $
HVNJ*OD"MM3JHIUT3FTFSWFE
ؔΛ·ͱΊΔ
ߏମܕΛఆٛ͢Δ
ࠞઢ͢Δؔܕͱ00
ؔܕͱ00
Ϟδϡʔϧͷͭͷׂ
defmodule User do
defstruct name: nil, age: nil
def new(name, age) do
%User{name: name, age: age}
end
def puts_name(%User{name: name}) do
IO.puts name
end
end
Ϋϥεఆٛ
ʹݟ͑Δ
ߨٛϊʔτ
ɹΫϥεఆٛʹݟ͑Δͱ
Կ͕͍͚ͳ͍ͷ͔ʁ