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
820
Elixir完全に理解した
(完全に理解したとは言っていない)。解説的。
さっちゃん
September 05, 2018
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.3k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.2k
path 依存型って何?
ne_sachirou
0
540
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
610
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
76
名實一致
ne_sachirou
0
630
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
3k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
910
Monitoring Containerized Elixir
ne_sachirou
1
940
Other Decks in Programming
See All in Programming
負債になりにくいCSSをデザイナとつくるには?
fsubal
10
2.6k
LINE messaging APIを使ってGoogleカレンダーと連携した予約ツールを作ってみた
takumakoike
0
110
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1.2k
sappoRo.R #12 初心者セッション
kosugitti
0
280
Rubyと自由とAIと
yotii23
6
1.8k
Formの複雑さに立ち向かう
bmthd
1
940
Unity Android XR入門
sakutama_11
0
180
PRレビューのお供にDanger
stoticdev
1
230
Ruby on cygwin 2025-02
fd0
0
180
機能が複雑化しても 頼りになる FactoryBotの話
tamikof
0
160
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
990
CDK開発におけるコーディング規約の運用
yamanashi_ren01
2
250
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
Rails Girls Zürich Keynote
gr2m
94
13k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Your Own Lightsaber
phodgson
104
6.2k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
Done Done
chrislema
182
16k
Building Applications with DynamoDB
mza
93
6.2k
Bootstrapping a Software Product
garrettdimon
PRO
306
110k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
A better future with KSS
kneath
238
17k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
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完全に理解した