Slide 1

Slide 1 text

Let's create stateful systems, by Elixir

Slide 2

Slide 2 text

. 。oO( さっちゃんですよヾ( 〃l _ l) ノ゙☆)

Slide 3

Slide 3 text

I'll show you a number.

Slide 4

Slide 4 text

2

Slide 5

Slide 5 text

Two

Slide 6

Slide 6 text

Slide 7

Slide 7 text

Slide 8

Slide 8 text

2 is a number of collison & collaboration.

Slide 9

Slide 9 text

I & you hot & ice stand up & lie down inside & outside

Slide 10

Slide 10 text

stateless & stateful

Slide 11

Slide 11 text

Function is stateless. f : x -> y e.g. Web server

Slide 12

Slide 12 text

Dialogue is stateful. Alice : X. Bob : Y. Alice : X. Bob : Z. Most of the system is stateful.

Slide 13

Slide 13 text

Elixir

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Elixir has processes. 29 = Task.async(fn -> 29 end) |> Task.await

Slide 16

Slide 16 text

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))

Slide 17

Slide 17 text

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!

Slide 18

Slide 18 text

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)

Slide 19

Slide 19 text

We can create stateful system easy, by constructing stateless parts.

Slide 20

Slide 20 text

How we can start Elixir? Let's create some applications. * Web application with Phoenix. * Slack bot.

Slide 21

Slide 21 text

Phoenix is a Web application framework that familiar with WebSocket. https://hexdocs.pm/phoenix/overview.html

Slide 22

Slide 22 text

React is available (✿ >ヮ ╹ )-♡ Let's create a realtime interaction ∩ (> ◡ <*)∩ ♡ https://speakerdeck.com/ne_sachirou/phoenix-livereact

Slide 23

Slide 23 text

Create a Slack bot. https://github.com/BlakeWilliams/Elixir-Slack (Easy, so no topic.)

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Text editor? VSCode with mjmcloug.vscode-elixir works.

Slide 26

Slide 26 text

Format & lint. InnerCotton https://github.com/ne-sachirou/inner_cotton is a set of standard development tools. mix cotton.init mix cotton.lint --fix

Slide 27

Slide 27 text

Docker image (You need Docker :-) Fix major ver.s both Erlang & Elixir. docker run -it --rm nesachirou/elixir:1.9_erl22

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

https://speakerdeck.com/ne_sachirou/elixirwan-quan-nili-jie-sita

Slide 30

Slide 30 text

Advanced resources

Slide 31

Slide 31 text

Erlang in Anger https://ymotongpoo.github.io/erlang-in-anger/text-ja.pdf You want to read this… before production.

Slide 32

Slide 32 text

https://speakerdeck.com/ne_sachirou/sutetohurudeda-gui-mo- akusesufalsearusoft-realtimenagemusabawoeasynitukuru

Slide 33

Slide 33 text

https://speakerdeck.com/ne_sachirou/elixir-on-containers

Slide 34

Slide 34 text

https://speakerdeck.com/ne_sachirou/phoenix-at-scale

Slide 35

Slide 35 text

https://speakerdeck.com/ne_sachirou/ddd-data-driven-development