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
480
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
570
メトリックはいかにして見え續ける樣になったか #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
830
Monitoring Containerized Elixir
ne_sachirou
1
910
Other Decks in Programming
See All in Programming
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
最新TCAキャッチアップ
0si43
0
140
初めてDefinitelyTypedにPRを出した話
syumai
0
410
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
subpath importsで始めるモック生活
10tera
0
300
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Arm移行タイムアタック
qnighy
0
330
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
930
CSC509 Lecture 12
javiergs
PRO
0
160
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Embracing the Ebb and Flow
colly
84
4.5k
Statistics for Hackers
jakevdp
796
220k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Writing Fast Ruby
sferik
627
61k
Producing Creativity
orderedlist
PRO
341
39k
Mobile First: as difficult as doing things right
swwweet
222
8.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完全に理解した