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
600
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
74
名實一致
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
Flutter × Firebase Genkit で加速する生成 AI アプリ開発
coborinai
0
170
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
220
技術を改善し続ける
gumioji
0
120
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
920
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
920
15分で学ぶDuckDBの可愛い使い方 DuckDBの最近の更新
notrogue
3
460
ML.NETで始める機械学習
ymd65536
0
230
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
300
Jakarta EE meets AI
ivargrimstad
0
340
Visual StudioのGitHub Copilotでいろいろやってみる
tomokusaba
1
210
苦しいTiDBへの移行を乗り越えて快適な運用を目指す
leveragestech
0
1k
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
14k
Building Adaptive Systems
keathley
40
2.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Thoughts on Productivity
jonyablonski
69
4.5k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
510
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
It's Worth the Effort
3n
184
28k
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完全に理解した