Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Elixir完全に理解した
Search
さっちゃん
September 05, 2018
Programming
0
780
Elixir完全に理解した
(完全に理解したとは言っていない)。解説的。
さっちゃん
September 05, 2018
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.1k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.1k
path 依存型って何?
ne_sachirou
0
460
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
560
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
69
名實一致
ne_sachirou
0
610
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
3k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
810
Monitoring Containerized Elixir
ne_sachirou
1
900
Other Decks in Programming
See All in Programming
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.4k
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
EventSourcingの理想と現実
wenas
5
2k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
140
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
250
組織に自動テストを書く文化を根付かせる戦略(2024秋版) / Building Automated Test Culture 2024 Autumn Edition
twada
PRO
10
4.5k
色々なIaCツールを実際に触って比較してみる
iriikeita
0
230
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
8
930
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
190
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
280
Prompt Engineering for Developers @ AWS Community Day Adria 2024
slobodan
0
120
Featured
See All Featured
Side Projects
sachag
452
42k
Practical Orchestrator
shlominoach
186
10k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
How GitHub (no longer) Works
holman
311
140k
RailsConf 2023
tenderlove
29
880
Scaling GitHub
holman
458
140k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Measuring & Analyzing Core Web Vitals
bluesmoon
1
37
Rails Girls Zürich Keynote
gr2m
93
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.6k
Writing Fast Ruby
sferik
626
60k
Producing Creativity
orderedlist
PRO
341
39k
Transcript
Elixir完全に理解した
.。oO(さっちゃんですよヾ(〃l _ l)ノ゙✩)
2018/06/16
@ 秋葉原 東京
Erlang & Elixir Fest 2018
劃期的なグラフ現る
經驗
經驗 自信
經驗 自信 Elixir完全に理解した
經驗 自信 Elixir完全に理解した Elixir全然わからん
經驗 自信 Elixir完全に理解した Elixir全然わからん Elixirチョットデキル
Elixir完全に理解した
Erlang & Elixirで世界は、 チャットサーバーを作り(LINE、LoL - Riot Games、Discord、enza)、 大量メール配信システムを作り(ユミルリンク)、 ニコ生を作り、 課金APIサーバーを作り(gumi)、
廣告APIサーバーを作り (Dreevee)、 〜を作り…
Elixirを皆さんは、 完全に理解する。
Process Functional Macro
Process Functional Macro
Processes are parallel.
Task 1 Task 2 t Task 1 Task 2 t
t Non-parallel (just concurrent) Parallel
Parallel computation has multiple timelines. Each processes has independent timelines.
How processes work. send/2 register/2 monitor/1
How processes work. send/2 register/2 monitor/1
send(宛て先, message) Process Process pid send(pid, msg) msg VM
How processes work. send/2 register/2 monitor/1
Process.register(pid, process_name) Process Process pid send(name, msg) msg VM Registry
name → pid register(name, pid)
Erlang (Elixir) <> Go
VM Proc Proc go channel go channel Erlang uses 宛て先
Go uses channel
How processes work. send/2 register/2 monitor/1
Process.monitor(pid | process_name) Process monitor(pid) Process {:DOWN, process} VM monitor
Process Process VM dead
Process.link(pid | process_name) Process link(pid) Process exit VM monitor Process
Process VM dead monitor
Process.link(pid | process_name) Process link(pid) Process exit VM monitor Process
Process VM monitor dead
(Parallel + send/2 + register/2 + monitor/1) makes ↓ GenServer
(Easy process), Supervisor (Easy monitor), :gen_event (Event handler manager), :gen_statem (State machine process), :gen_tcp (Async TCP I/O), Task (Easy background & parallel task), Agent (Easy state), GenStage (Parallel workflow), Flow (Easy GenStage), Registry (Distributed process registry), :rpc (Call remote node with no-border)
Process Functional Macro
Functional programming (函數型programming)
Ruby JavaScript C++, Objective C, Swift C# are not (or
partially) functional.
Programming languages that built on functional programming : Lisp (Emacs
Lisp, Common Lisp, Scheme, Racket, Clojure…) ML (SML, OCaml, F#…) Markov algorithm (Pure, Mathematica…) Proof assistant (Coq, Agda, Idris, F*…) Concatenative (Joy, Factor, Kitten, …) Haskell, PureScript, Erlang, Scala, Lazy K, Elm, APL/J…
Programming languages that built on functional programming : Lisp (Emacs
Lisp, Common Lisp, Scheme, Racket, Clojure…) ML (SML, OCaml, F#…) Markov algorithm (Pure, Mathematica…) Proof assistant (Coq, Agda, Idris, F*…) Concatenative (Joy, Factor, Kitten, …) Haskell, PureScript, Erlang, Scala, Lazy K, Elm, APL/J…
Recipe of Elixir : Clojure Erlang Ruby Elixir
Recipe of Elixir : Build Clojure (Lisp on JVM) in
Ruby form on top of Erlang.
Elixir is functional. Higher-order function Immutable data No implicit state
(except process & macro)
Elixir is functional. Higher-order function : Enum.map(1..42, &(&1 + 1))
Elixir is functional. Immutable data : data = update_in(data.a.b, &(&1
|| 42))
Elixir is functional. No implicit state (except process & macro)
: def get(key, state), do: {state[key], state}
Elixir is functional. Strong abstraction mechanism (See Haskell). Good debuggability.
Good testability.
※Column Debugging tools for Elixir : :observer :observer_cli (3rd party)
ReconTrace (3rd party wrapper of official :dbg) :fprof :eflame (3rd party)
Process Functional Macro
Recipe of Elixir : Build Clojure (Lisp on JVM) in
Ruby form on top of Erlang.
Clojure & Ruby has nice meta-programming mechanism. Elixir has macro.
Macro is a function which convert a program to a
program.
Use Case : GenServer To reduce boilerplate codes. defmodule Example
do use GenServer End GenServer.start_link(Example, nil)
Use Case : Ecto To write declarative code (DSL). defmodule
User do use Ecto.Schema schema “user” do field :name, :string, default: “ももんが” end end
Use Case : with_context (in our product) Implicit programming. card
= with_context(context, get_card!(1)) ↑ {card, context} = get_card!(1, context) card
Elixir has Parallel process Functional Productive macro
Erlang & Elixir’s ecosystem : Web application (Phoenix, Ecto, Quantum)
Bot (Hedwig) Web browser frontend (ElixirScript, Elchemy) IoT (Nerves, GRiSP) BlockChain (æternity) 3D modeling (Wings 3D) Message Queue (RabbitMQ, VerneMQ) DB (Riak, LeoFS)
Elixir完全に理解した