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
790
Elixir完全に理解した
(完全に理解したとは言っていない)。解説的。
さっちゃん
September 05, 2018
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.2k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.1k
path 依存型って何?
ne_sachirou
0
500
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
580
メトリックはいかにして見え續ける樣になったか #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
850
Monitoring Containerized Elixir
ne_sachirou
1
920
Other Decks in Programming
See All in Programming
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
100
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
130
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
6
1.1k
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
790
快速入門可觀測性
blueswen
0
370
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
780
Zoneless Testing
rainerhahnekamp
0
120
Security_for_introducing_eBPF
kentatada
0
110
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
440
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
910
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Building Adaptive Systems
keathley
38
2.3k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Code Review Best Practice
trishagee
65
17k
The Invisible Side of Design
smashingmag
298
50k
Making the Leap to Tech Lead
cromwellryan
133
9k
Fireside Chat
paigeccino
34
3.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
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完全に理解した