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

How to use Scala.js in real world?

C2dcf3e2f7861b2ec5d84045273ed5bd?s=47 kyo_ago
January 29, 2016

How to use Scala.js in real world?

C2dcf3e2f7861b2ec5d84045273ed5bd?s=128

kyo_ago

January 29, 2016
Tweet

Transcript

  1. How to use Scala.js in real world? Kyo Ago

  2. About me - work for ChatWork - using JavaScript for

    9 years - using Scala for 0.5 year ࣗݾ঺հɻChatWorkͰJavaScriptॻ͍ͯ·͢
  3. Scala is great! Scala͍͍Ͱ͢Ͷʂ

  4. But Ͱ΋

  5. We want to develop UI, don't we!? UIΛ࡞Γ͍ͨʂ

  6. Hmm... ͡Ό͋

  7. Scala.js!! Scala.jsͰ͢Ͷʂ

  8. Wait ... Ͱ΋

  9. Scala.js is production ready yet? Scala.js࢖͑Δͷʁ

  10. Yes, it is! ࢖͑Δ

  11. 1. "almost" compatible to Javascript JavaScriptͱͷޓ׵ੑ͸΄΅ສશ - bit-size in number

    types - runtime semantics in exceptions - difference of regex defs
  12. 2. Type definition can be applied by using TypeScript ܕఆٛ΋TypeScript͔ΒಋೖՄೳ

    sjrd/scala-js-ts-importer
  13. 3. fast compile ߴ଎ͳίϯύΠϧ 1-2 seconds even when optimized fullOptJS

    is used
  14. 4. small footprint ܰྔ Hello world! is 17KB(with fullOptJS). 6KB

    with gzip
  15. 5. supports SourceMap SourceMapαϙʔτ

  16. 6. Java API implementation is going actively Java APIͷ࣮૷΋ਐΜͰΔ

  17. Why isn't Scala.js widely used? ͡Ό͋ɺͳΜͰ࢖ΘΕͯͳ͍ͷʁ

  18. 1. type safety is too much for small projects খن໛ͳΒܕ҆શੑͷඞཁੑ͸௿͍

  19. 2. widely proven framework is preferred in large projects. େن໛ͳΒ࣮੷͕ͳ͍ϑϨʔϜϫʔΫ͸࠾༻͠ʹ͍͘

  20. 3. difficult to call Scala.js from Javascript JavaScript͔ΒScala.jsΛݺͼग़͢ͷ͕೉͍͠ The part

    actively developed right now
  21. 4. difficult to change if html was embedded to code

    ίʔυʹhtmlΛຒΊࠐΉͱUIมߋʹऑ͍
  22. 5. compatibility/ability to track the latest version between other JavaScript

    libraries JavaScriptϥΠϒϥϦͱͷޓ׵ੑɺ࠷৽൛΁ͷ௥ैੑ
  23. 6. debugging cost on browsers ϒϥ΢β্Ͱͷσόοάίετ

  24. Then, we can't use, can we!? ͡Ό͋ɺ࢖͑ͳ͍ͷʁ

  25. Architecture can be an answer ΞʔΩςΫνϟͰղܾ

  26. Scala.js should covers only logic. Scala.js͸ϩδοΫͷΈΛ࣮૷

  27. Javascript should covers UI JavaScriptͰUIΛ࣮૷

  28. communicate each other by JSON ͓ޓ͍ʹJSONͰ௨৴

  29. UI should be contsructed by JSON UI͸JSON͔Βߏங͢Δ

  30. Pros ར఺

  31. 1. reduces integration between Scala.js and JavaScript Scala.jsͱJavaScriptͷ࿈ܞ͕ݮΔ

  32. 2. we can develop in Scala.js similar to usual development

    in Scala ௨ৗͷScala։ൃͱಉ͡Α͏ʹScala.jsͰ։ൃͰ͖Δ
  33. 3. flexibility of implementing UI UI࣮૷ͷࣗ༝౓্͕͕Δ

  34. Cons ܽ఺

  35. 1. communication cost between Scala.js and UI Scala.jsͱUI෦෼ͱͷ௨৴͕සൃ͢Δ

  36. 2. logic is prone to be complex ϩδοΫ͕ෳࡶԽ͢Δ

  37. Is this really achievable? ࣮ݱՄೳʁ

  38. Yes, at least on the architecture level ΞʔΩςΫνϟతʹ͸Մೳ

  39. Let's discuss together at ChatWork Booth! ৄ͘͠͸ϒʔεͰ

  40. Thank you! ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ

  41. We're Hiring!! ͝Ԡื͓଴͍ͪͯ͠·͢ʂ http://corp.chatwork.com/ja/recruit/engineer/