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

ElmでWebサービスを作るふわっとしたお話

youku_s
December 02, 2017

 ElmでWebサービスを作るふわっとしたお話

NGK2017B(名古屋合同懇親会 2017忘年会) LT内容

youku_s

December 02, 2017
Tweet

Other Decks in Technology

Transcript

  1. ElmͬͯԿ • ߴ඼࣭ͳϑϩϯτΤϯυ։ൃΛߦ͏͜ͱʹಛԽͨ͠ݴޠ • AltJS • ൚༻ݴޠͰ͸ͳ͍ • HaskellͷαϒηοτΈ͍ͨͳݴޠ࢓༷Λ࣋ͭ •

    ElmΞʔΩςΫνϟͰ࢖͏͜ͱΛ૝ఆ͞Ε͍ͯΔ • ElmΛ࢖͏ͳΒɺ͜ΕҎ֎ͳ͍ • ಠࣗͷvdom࣮૷ͱɺঢ়ଶભҠϑϨʔϜϫʔΫΛ͍࣋ͬͯΔ • ͞Βʹৄ͘͠ • Elm͸ͲΜͳਓʹΦεεϝͰ͖ͳ͍͔ • https://qiita.com/arowM/items/dfb38d1c5f3dfde8b8bf
  2. ͳͥElm͔ɿͪΐͬͱ͚ͩਅ໘໨ʹ • vdomܥͷϑϨʔϜϫʔΫʹڵຯ͕͋ͬͨ • JSωΠςΟϒͩͱReact.jsɺVue.js͋ͨΓ͕ϝδϟʔʁ • Vue.js͸Α͘஌Βͳ͍ • ஌Βͳ͍΋ͷʹؔͯ͠͸௜໧͠ͳ͚Ε͹ͳΒͳ͍ •

    React.js͸Scalajs-reactܦ༝Ͱগ͠৮ͬͨ͜ͱ͕͋Δ • ঢ়ଶભҠϑϨʔϜϫʔΫͱ๊͖߹ΘͤΔඞཁ͕͋Δ • Reduxͱ͔ • ͪΐͬͱΊΜͲ͏͍͘͞
  3. ͳͥElm͔ɿͪΐͬͱ͚ͩਅ໘໨ʹ • ͦ΋ͦ΋ɺJSΛͳΔ΂͘ੜͰॻ͖ͨ͘ͳ͍ • AltJS࢖͏ػӡ • TypeScriptɿ୅਺తσʔλܕ͕ͳ͍ͷͰ͍΍ͩ • Haxeɿۀ຿Ͱे෼৮͔ͬͨΒ͍͍΍ •

    Scala.jsɿे෼৮͔ͬͨΒ͍͍΍ • Elmɿਪ঑ΞʔΩςΫνϟʹ৐Ε͹vdom΋ঢ়ଶભҠϑϨʔϜϫʔΫ΋αϙʔτ ͞Ε͍ͯΔɺܕڧ͍ • ͳʹΑΓɺࢲͷܦݧ஋͕·ͩগͳ͍
  4. γεςϜߏ੒ • AWSΛ࢖ͬͨαʔόʔϨεΞʔΩςΫνϟ • ؒҧ͍ͬͯͨΒ͝ΊΜͳ͍͞ Amazon CloudFront Amazon
 Route 53

    Amazon API Gateway Amazon S3 ʢHTML+JS+ը૾ͳͲʣ AWS Lambda Amazon
 DynamoDB
  5. ElmͲ͏ͩͬͨʁɿྑ͍఺ • ܕ͕ڧ͍ͷ͸خ͍͠ • ϨϯμϦϯά͕ૣ͍ʁ • http://elm-lang.org/blog/blazing-fast-html-round-two (ͪΐͬͱݹ͍) • ঢ়ଶͱΠϕϯτͷ૊Έ߹ΘͤΛ൱Ԡͳ͘ߟ͑ͤ͞ΒΕΔ

    • ߟྀ࿙Ε͕ݮΔ • ҎલͷElmͱൺ΂ͯ • ੜJSͱͷ࿈ܞָ͕ʹͳ͍ͬͯΔ • ඇಉظॲཧɺ෭࡞༻ΛؚΉॲཧͷ੾Γग़ָ͕͠ʹͳ͍ͬͯΔ • 2byteจࣈͷѻ্͍͕ख͘ͳ͍ͬͯΔ
  6. ElmͲ͏ͩͬͨʁɿѱ͍఺ • JSONΛऔΓѻ͏ͷ͕ͭΒ͍ • Elm to JSONɺJSON to Elmͱ΋ʹඇৗʹ୔ࢁίʔυΛॻ͔͞ΕΔ •

    json4sΈ͍ͨͳͷ͕΄͍͠ • ϦϑϨΫγϣϯͳ͍͠ɺPure ElmͰ͸ͨͿΜແཧͦ͏ʁ • ग़ྗ͞ΕΔJSͷαΠζ͕େ͖͍ • ࠓճͷΞϓϦέʔγϣϯͩͱɺminifyͯ͠΋400kb↑ • CloudFront࢖͍ͬͯΔͷ͸ओʹ͍͕ͭ͜ݪҼ • View͕ϓϩάϥϚҎ֎ʹಡΊͳ͍/ॻ͚ͳ͍ • σβΠφͱڠۀ͢Δʹ͸ɺhtmlϥΠΫͳςϯϓϨʔτΛElmͷViewʹม׵͢Δ΋ͷ͕ඞཁͦ ͏
  7. ײ૝ • ָ͔ͬͨ͠ • ֶशίετ͸ߴ͍ • μΠΞϩάɺλϒͳͲগ͠ڽͬͨίϯϙʔωϯτΛ࢖͏ͳΒɺεΫϥονͰॻ͚ Δఔ౓ͷ࣮ྗ͕ͳ͍ͱͭΒ͍ • ElmΞʔΩςΫνϟΛ֮͑Δͷ͸ɺҰ͔ΒReact.js࢝ΊΔͷͱ͍ͨͯ͠มΘΒͳ

    ͍ؾ΋͢Δ • Haskellͷॻ͖ํ๨Ε͚ͨΕͲɺಛʹ໰୊ͳ͘ॻ͚·ͨ͠ • ݱঢ়Ͱ΋ͦΕͳΓʹ࢖͑ͦ͏ʁʁʁ • աڈʹ௒ഁյతมߋ΍Β͔͍ͯ͠ΔͷͰɺv1.0ʹͳΔ·Ͱ͸੩؍͕ඞཁͦ͏