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

Elixir完全に理解した

 Elixir完全に理解した

(完全に理解したとは言っていない)。解説的。

さっちゃん

September 05, 2018
Tweet

More Decks by さっちゃん

Other Decks in Programming

Transcript

  1. Task 1 Task 2 t Task 1 Task 2 t

    t Non-parallel (just concurrent) Parallel
  2. (Parallel + send/2 + register/2 + monitor/1) makes ↓ GenServer

    (Easy process), Supervisor (Easy monitor), :gen_event (Event handler manager), :gen_statem (State machine process), :gen_tcp (Async TCP I/O), Task (Easy background & parallel task), Agent (Easy state), GenStage (Parallel workflow), Flow (Easy GenStage), Registry (Distributed process registry), :rpc (Call remote node with no-border)
  3. Programming languages that built on functional programming : Lisp (Emacs

    Lisp, Common Lisp, Scheme, Racket, Clojure…) ML (SML, OCaml, F#…) Markov algorithm (Pure, Mathematica…) Proof assistant (Coq, Agda, Idris, F*…) Concatenative (Joy, Factor, Kitten, …) Haskell, PureScript, Erlang, Scala, Lazy K, Elm, APL/J…
  4. Programming languages that built on functional programming : Lisp (Emacs

    Lisp, Common Lisp, Scheme, Racket, Clojure…) ML (SML, OCaml, F#…) Markov algorithm (Pure, Mathematica…) Proof assistant (Coq, Agda, Idris, F*…) Concatenative (Joy, Factor, Kitten, …) Haskell, PureScript, Erlang, Scala, Lazy K, Elm, APL/J…
  5. Elixir is functional. No implicit state (except process & macro)

    : def get(key, state), do: {state[key], state}
  6. ※Column Debugging tools for Elixir : :observer :observer_cli (3rd party)

    ReconTrace (3rd party wrapper of official :dbg) :fprof :eflame (3rd party)
  7. Use Case : GenServer To reduce boilerplate codes. defmodule Example

    do use GenServer End GenServer.start_link(Example, nil)
  8. Use Case : Ecto To write declarative code (DSL). defmodule

    User do use Ecto.Schema schema “user” do field :name, :string, default: “ももんが” end end
  9. Use Case : with_context (in our product) Implicit programming. card

    = with_context(context, get_card!(1))             ↑ {card, context} = get_card!(1, context) card
  10. Erlang & Elixir’s ecosystem : Web application (Phoenix, Ecto, Quantum)

    Bot (Hedwig) Web browser frontend (ElixirScript, Elchemy) IoT (Nerves, GRiSP) BlockChain (æternity) 3D modeling (Wings 3D) Message Queue (RabbitMQ, VerneMQ) DB (Riak, LeoFS)