Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Let's create stateful systems, by Elixir

Let's create stateful systems, by Elixir

さっちゃん

August 24, 2019
Tweet

More Decks by さっちゃん

Other Decks in Programming

Transcript

  1. 2

  2. Two

  3. I & you hot & ice stand up & lie

    down inside & outside
  4. Dialogue is stateful. Alice : X. Bob : Y. Alice

    : X. Bob : Z. Most of the system is stateful.
  5. 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
  6. 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))
  7. 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!
  8. 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)
  9. How we can start Elixir? Let's create some applications. *

    Web application with Phoenix. * Slack bot.
  10. React is available (✿ >ヮ ╹ )-♡ Let's create a

    realtime interaction ∩ (> ◡ <*)∩ ♡ https://speakerdeck.com/ne_sachirou/phoenix-livereact
  11. 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
  12. Docker image (You need Docker :-) Fix major ver.s both

    Erlang & Elixir. docker run -it --rm nesachirou/elixir:1.9_erl22
  13. 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