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
580
Let's create stateful systems, by Elixir
さっちゃん
August 24, 2019
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
26
名實一致
ne_sachirou
0
490
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
2.4k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
390
Monitoring Containerized Elixir
ne_sachirou
1
620
Phoenix LiveReact
ne_sachirou
1
330
Phoenix LiveView チュートリアル
ne_sachirou
1
130
DDD: Data Driven Development
ne_sachirou
6
4.6k
Elixir on Containers
ne_sachirou
1
680
Other Decks in Programming
See All in Programming
Workshop on Jetpack compose
aldefy
0
140
レガシーフレームワークからの移行
ug
0
120
Remix + Cloudflare Pages + D1 で ポケモン SV のレンタルチームを検索できるアプリを作ってみた
kuroppe1819
4
1.4k
jq at the Shortcuts
cockscomb
1
430
Use KMM to call the API of the National Tax Agency
akkeylab
0
300
What's new in Shopware 6.5
shyim
0
110
新卒でサービス立ち上げから Hasuraを使って3年経った振り返り
yutorin
0
230
AWSにおける標的型Bot対策
hacomono
0
420
Functional Data Engineering - A Blueprint for adopting functional principles in data pipeline
vananth22
0
190
Remote SSHで行うVS Codeリモートホスト開発とトラブルシューティング
smt7174
1
490
Writing Greener Java Applications
hollycummins
0
340
Findy - エンジニア向け会社紹介 / Findy Letter for Engineers
findyinc
2
42k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
69
5.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
254
12k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
239
19k
Optimizing for Happiness
mojombo
365
64k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
217
21k
Docker and Python
trallard
30
1.9k
Designing on Purpose - Digital PM Summit 2013
jponch
108
5.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
1.2k
The Web Native Designer (August 2011)
paulrobertlloyd
76
2.2k
Clear Off the Table
cherdarchuk
79
290k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
500
130k
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