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

次の10年のためにElixirをハックする

 次の10年のためにElixirをハックする

shibuya.ex#1での資料

3aebd86547bfc5cdb451d5f2f95ed5d8?s=128

Koutarou Chikuba

August 25, 2015
Tweet

More Decks by Koutarou Chikuba

Other Decks in Technology

Transcript

  1. ࣍ͷ10೥ͷҝʹElixirΛϋοΫ͢ Δ mizchi @Shibuya.ex #1

  2. About ☞ ήʔϜձࣾ → ڭҭܥϕϯνϟʔ → Increments Inc(Qiita) ☞ JavaScript(Frontend/Node.js)

    / ͪΐͬͱRuby ☞ Kobito for Windows ϝΠϯ։ൃऀ ☞ ֶੜ࣌୅ʹҰਓͰMMOΈ͍ͨͳͷ࡞ͬͯͨ
  3. @mizchiͷڵຯ ☞ WebSocket౳ͷϦΞϧλΠϜॲཧʹڵຯ ☞ Erlang/Elixir͋Μ·ΓษڧͰ͖ͯͳ͍ ☞ ٕज़తʹத਎͕͋Δ࿩͸͠ͳ͍(Ͱ͖ͳ͍)

  4. ElixirͰҰൃ౰͍ͯͨ

  5. Elixir͸Ͳ͏͍͏ݴޠ͔ ☞ จ๏͸RubyͰத਎͸Erlang ☞ ৄ͘͠͸@naoya͞Μ͕ޠͬͯ͘ΕΔ(ͨ)Ͱ͠ΐ͏

  6. ͸͡Ίʹ

  7. ੜଘઓུ ☞ ڈ೥ɺͲ͏ʹ͔ͯ͠࢓ࣄͰReact.jsΛ࢖͍͔ͨͬͨ ☞ React঺հهࣄΛॻ͖·ͬͨ͘ ☞ ΈΜͳགྷΕʙʙʙ

  8. ੒ޭͨ͠

  9. ࠓ೥ ☞ Elixir? ☞ ϦΞϧλΠϜ΢Σϒͳ؍఺͔ΒElixir / Phoenix ʹ͍ͭͯ - Qiita

    Λॻ͍ͨ ☞ ʮnaoya͞Μ, elixir·͍͍͢͡Αʂ΍Γ·͠ΐ͏Αʂʯͬͯݴ͍ ·ͬͨ͘ΒWeb+DbͰ࿈ࡌ࢝·ͬͨ
  10. Ͱ΋·ͩϙςϯγϟϧʹ֬ূ͕ ͳ͍

  11. ࠓ೔Զʹ֬ূΛ͘Ε!!

  12. ࣗ෼ͱElixirͷग़ձ͍ ☞ ౰࣌ͷಉ྅ͷ@udzura ͞Μʹ༠ΘΕͯୈҰճshinjuku.ex ʹࢀ Ճ ☞ http://d.hatena.ne.jp/mizchi/20120312/1331566107 ☞ StrangeLoop2014(ήςϞϊݴޠͷࡇయ)ͰଘࡏΛࢥ͍ग़͢

    ☞ "Elixir and the Internet of Things" by Doug Rohrer - YouTube ☞ ͳΜ͔1.0ग़ͯͨ ☞ Elixir v1.0 released - Elixir
  13. ੝Γ্͕ͬͯΔʁ ☞ HackerNewsํ໘Ͱݴٴ͕͍͢͝૿͑ͨ ☞ Ұൃ౰ͯͦ͏ͳؾ഑

  14. ٱ͠ͿΓʹ৮ͬͯΈΔ ☞ γϯλοΫε͸(ද໘తʹ͸)͋Μ·ΓมΘͬͯͳ͍ ☞ ৽ଔ౰࣌Θ͔Βͳ͔ͬͨErlangͷϝϞϦϞσϧͷੌ͕͞ɺࠓ͸ Θ͔ΔΑ͏ʹͳͬͨ ☞ ੲͳ͔ͬͨmix͍͢͝ศར ☞ mix࠷ߴͰ͸

  15. ͜͜ͰϞμϯͳݴޠΛৼΓฦΔ ☞ ruby / rubygems ☞ node / npm ☞

    rust / cargo
  16. Package Manager Is First Priority? ☞ ྲྀߦͬͯΔLL = ඞͣྑ͍ϑΝʔετͷύοέʔδϚωʔδϟ͕ ͋Δ

    ☞ Elixir͸ύοέʔδϚωʔδϟ݉Ϗϧυπʔϧͷ׬੒౓Ͱάϯͱ ෑډԼ͖͛ͯͨ ☞ (ࠓ͔Βݴޠ࡞ͬͯҰൃ౰͍ͯͨਓ͸ύοέʔδϚωʔδϟ͔Β ࡞Δͱྑͦ͞͏)
  17. ϦΞϧλΠϜ΢Σϒ ☞ HTTP2 ☞ WebSocket ☞ WebRTC

  18. WebSocketΛͱΓ·͘ݱঢ়: Ұੲલ ☞ Socket.IOҰ୒ ☞ Socket.IOͷӢߦ͖͕ո͍࣌͠୅͕͋ͬͨ ☞ 1೥൒͙Β͍ϝϯς͞Εͳ͔ͬͨ ☞ nodeͷӡ༻໘౗

    ☞ γϯάϧϧʔϓͷnodeͷରো֐ੑ͸ׂͱ࠷ѱͷ෦ྨ
  19. WebSocketΛͱΓ·͘ݱঢ়: ࠷ۙ ☞ WebSocketରԠϒϥ΢β͕૿͑ͨ ☞ ϑΥʔϧόοΫͷॏཁ౓ͷݮগ ☞ PaaSʹΑΔఏڙ ☞ Pusher

    ☞ Firebase
  20. PaaSΛ࢖ͬͨݱ࣮ ՝ۚϓϥϯͰ༻్੍͕ݶ͞ΕΔ

  21. ୡ੒͍ͨ͠ ☞ ࣗલͰ௿ϨΠςϯγͰରো֐ੑ͕ߴ͍(Web)Socket αʔόʔͷ ߏங͕؆୯ʹͳͬͯ΄͍͠ ☞ ͍ͭͰʹ Rails ͱ͔΋౗͍ͨ͠

  22. ະདྷ? ☞ Ruby: rails/activecable ☞ Elixir: Phoenix/Channel

  23. ϞμϯͳWAFʹٻΊΒΕΔ΋ͷ

  24. ϞμϯͳHTML/SPAͷ෩ை ☞ ΋͏ೝূͱJSON API͚ͩͰΑ͘Ͷʁ ☞ Ή͠Ζଞͷػೳ͸अຐ ☞ Google ͕ΫϩʔϧؤுΔ or

    ΤϯδχΞ͕SSRؤுΕ͹ΫϥΠΞ ϯτ/αʔόʔͰςϯϓϨʔτ୯ҰԽ͸Մೳ ☞ ςϯϓϨʔτʹ͍ͭͯγʔϜϨεͳ౷߹Λ੒͠਱͛Ε͹ ͘͢͝ ͔͍͍ͬ͜ ؾ͕͢Δ
  25. react-phoenix ☞ Λͭ͘Ζ͏ͱͨ͠ ☞ react-railsͷίʔυಡΜͰଞͷ؀ڥͰ΋࣮ݱͰ͖ͦ͏ͱ͍͏͜ͱ ͕Θ͔ͬͨ ☞ WIP

  26. ʮ͋ͱ͸ͭ͘Δ͚ͩʂʯ {:ok, vm} = :erlang_v8.start_vm(file:"node_modules/react/dist/react.min.js") {:ok, ret}:erlang_v8.eval vm, "React.renderToString(React.createElement('div', {}))

    # "<div data-reactid=\".3y56pmq0ow\" data-react-checksum=\"-75887465\"></div>"}
  27. Elixir΁ͷෆຬ ☞ 2015೥ʹ͍·͞Βܕ͕ͳ͍ݴޠΛֶͿͳΜͯײ ☞ ύλʔϯϚονͰ͋Δఔ౓ϨίʔυΛ໌ࣔͰ͖Δ ☞ dialyzer Λ࢖͏ / ref.

    ੩తܕνΣοΫπʔϧDialyzerΛElixir ͔Β࢖͏ - Qiita ☞ Ҿ਺͕ҧ͏ɺ౳ͷ͋Δఔ౓ࣗ໌ͳ΋ͷ͸࣮ߦલʹ஄͍ͯΔ
  28. dializerͷྫ defmodule Simple do @type atom_list :: list(atom) @spec count_atoms(atom_list)

    :: non_neg_integer def count_atoms(list) do # ... end end
  29. Elixirʹղܾͯ͠ཉ͍͠໰୊ ☞ ϦΞϧλΠϜ΢Σϒ͸௨৴ස౓͕ߴ͍ ☞ σουϙΠϯτΛ౿ΉՄೳੑ͕ߴ͍ => Let it crash ͨ͠͞

    ☞ খ͞ͳύέοτɾϓϩηε͕େྔʹඈͼަ͏ ☞ GCηϯγςΟϒ => ErlangVMͰղܾ͍ͨ͠
  30. ຊԻ ☞ ͭ·Βͳ͍ݴޠͰফ໣ͨ͘͠ͳ͍ ☞ ElixirΈ͍ͨͳ໘നػೳੵΜͩݴޠྲྀߦͬͯ͘Ε

  31. ׂΓ੾Γ ☞ Erlang ͸ ݁ہ Network DSL ݴޠͱׂͯ͠Γ੾ͬͨํ͕ྑ͍(by @volutans) ☞

    ಘҙͳ͜ͱ͸ѹ౗తʹಘҙ͕ͩͦΕҎ֎͸ผʹ… ☞ CPUϔϰΟͳϓϩάϥϜ͕ૣ͘ͳΔΘ͚Ͱ͸ͳ͍
  32. (๻͕)ษڧʹͳͬͨࢿྉ node.js vs Erlang (ωλ) - kuenishi's blog

  33. ͓ΘΓ