Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Let's create stateful systems, by Elixir
さっちゃん
August 24, 2019
Programming
1
520
Let's create stateful systems, by Elixir
さっちゃん
August 24, 2019
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
名實一致
ne_sachirou
0
470
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
2.3k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
330
Monitoring Containerized Elixir
ne_sachirou
1
520
Phoenix LiveReact
ne_sachirou
1
280
Phoenix LiveView チュートリアル
ne_sachirou
1
110
DDD: Data Driven Development
ne_sachirou
6
4.4k
Elixir on Containers
ne_sachirou
1
620
發言の超越論的な根拠
ne_sachirou
1
170
Other Decks in Programming
See All in Programming
Reactは何を提供するLibraryなのか?
taro28
3
460
GoogleI/O2022 LT報告会資料
shinsukefujita1126
0
380
JetPackComposeは宣言型プログラミングパラダイムって実はよくわかってないんですが、別に使ってもいいんですよね、
conigashima
0
190
Lancersをコンテナへ本番移行する取り組み
rvirus0817
1
400
Cross Deviceチームにおけるスマートテレビアプリ開発ってどんな感じ?
cokaholic
0
120
Let's keep Commodore 64 alive for the next 40 years
mehowte
1
110
クックパッドマートの失敗したデータ設計 Before / After 大放出
mokuzon
0
180
From Java through Scala to Clojure
lagenorhynque
0
230
オブジェクト指向で挫折する初学者へ
deepoil
0
180
Scrum Fest Osaka 2022/5年で200人になったスタートアップの アジャイル開発の歴史とリアル
atamaplus
1
930
heyにおけるCI/CDの現状と課題
fufuhu
3
560
NEWT.net: Frontend Technology Selection
xpromx
0
250
Featured
See All Featured
Code Review Best Practice
trishagee
43
9.3k
4 Signs Your Business is Dying
shpigford
169
20k
The Art of Programming - Codeland 2020
erikaheidi
32
11k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
The Straight Up "How To Draw Better" Workshop
denniskardys
225
120k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
37
3.3k
Optimizing for Happiness
mojombo
365
63k
How STYLIGHT went responsive
nonsquared
85
3.9k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_i
23
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
5
510
VelocityConf: Rendering Performance Case Studies
addyosmani
316
22k
How GitHub (no longer) Works
holman
296
140k
Transcript
Let's create stateful systems, by Elixir
. 。oO( さっちゃんですよヾ( 〃l _ l) ノ゙☆)
I'll show you a number.
2
Two
Ⅱ
⼆
2 is a number of collison & collaboration.
I & you hot & ice stand up & lie
down inside & outside
stateless & stateful
Function is stateless. f : x -> y e.g. Web
server
Dialogue is stateful. Alice : X. Bob : Y. Alice
: X. Bob : Z. Most of the system is stateful.
Elixir
Elixir is a functional programming language. Functional programming is stateless.
All data of Elixir is immutable. [x, 3, x] = Enum.map([1,2,1], &(&1 + 1)) assert 2 == x // Many lines that don't reassign to `x`. assert 2 == x
Elixir has processes. 29 = Task.async(fn -> 29 end) |>
Task.await
Process has state. agent = Agent.start_link(fn -> 29 end) 29
= Agent.get(agent, &(&1)) Agent.update(agent, &(&1 + 13)) 42 = Agent.get(agent, &(&1))
State should be updated in a transaction. State shold interact
& isolate each other. Accessing to state should be scaled in-out. Server with state should be updated gracefully. Elixir has all of these!
State should be updated in a transaction. (No shared state)
State shold interact & isolate each other. (Application, Supervisor) Accessing to state should be scaled in-out. (GenStage, Task, Register, Erlang cluster) Server with state should be updated gracefully. (Hot code swap)
We can create stateful system easy, by constructing stateless parts.
How we can start Elixir? Let's create some applications. *
Web application with Phoenix. * Slack bot.
Phoenix is a Web application framework that familiar with WebSocket.
https://hexdocs.pm/phoenix/overview.html
React is available (✿ >ヮ ╹ )-♡ Let's create a
realtime interaction ∩ (> ◡ <*)∩ ♡ https://speakerdeck.com/ne_sachirou/phoenix-livereact
Create a Slack bot. https://github.com/BlakeWilliams/Elixir-Slack (Easy, so no topic.)
Installing Elixir. asdf https://asdf-vm.com/ asdf plugin-add erlang asdf install erlang
22.0.7 asdf plugin-add elixir asdf install elixir 1.9.1
Text editor? VSCode with mjmcloug.vscode-elixir works.
Format & lint. InnerCotton https://github.com/ne-sachirou/inner_cotton is a set of standard
development tools. mix cotton.init mix cotton.lint --fix
Docker image (You need Docker :-) Fix major ver.s both
Erlang & Elixir. docker run -it --rm nesachirou/elixir:1.9_erl22
Textbook & document. Official guide : https://elixir-lang.org/ Official document :
https://hexdocs.pm/elixir/Kernel.html Online textbook : https://elixirschool.com/ja/ Textbook : https://tatsu-zine.com/books/programming-elixir-ja
https://speakerdeck.com/ne_sachirou/elixirwan-quan-nili-jie-sita
Advanced resources
Erlang in Anger https://ymotongpoo.github.io/erlang-in-anger/text-ja.pdf You want to read this… before
production.
https://speakerdeck.com/ne_sachirou/sutetohurudeda-gui-mo- akusesufalsearusoft-realtimenagemusabawoeasynitukuru
https://speakerdeck.com/ne_sachirou/elixir-on-containers
https://speakerdeck.com/ne_sachirou/phoenix-at-scale
https://speakerdeck.com/ne_sachirou/ddd-data-driven-development