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
Let's create stateful systems, by Elixir
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
さっちゃん
August 24, 2019
Programming
1k
1
Share
Let's create stateful systems, by Elixir
さっちゃん
August 24, 2019
More Decks by さっちゃん
See All by さっちゃん
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.6k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.4k
path 依存型って何?
ne_sachirou
0
790
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
690
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
120
名實一致
ne_sachirou
0
720
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
3.2k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
1.1k
Monitoring Containerized Elixir
ne_sachirou
1
1.1k
Other Decks in Programming
See All in Programming
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.2k
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
200
Java 21/25 Virtual Threads 소개
debop
0
310
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
700
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
5.1k
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
730
Symfony + NelmioApiDocBundle を使った スキーマ駆動開発 / Schema Driven Development with NelmioApiDocBundle
okashoi
0
250
ロボットのための工場に灯りは要らない
watany
12
3.2k
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
350
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
200
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
110
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Navigating Team Friction
lara
192
16k
Music & Morning Musume
bryan
47
7.1k
Ruling the World: When Life Gets Gamed
codingconduct
0
190
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
310
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
170
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
490
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
160
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Curious Case for Waylosing
cassininazir
0
280
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