Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

About me - work for ChatWork - using JavaScript for 9 years - using Scala for 0.5 year ࣗݾ঺հɻChatWorkͰJavaScriptॻ͍ͯ·͢

Slide 3

Slide 3 text

Scala is great! Scala͍͍Ͱ͢Ͷʂ

Slide 4

Slide 4 text

But Ͱ΋

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Hmm... ͡Ό͋

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Wait ... Ͱ΋

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Yes, it is! ࢖͑Δ

Slide 11

Slide 11 text

1. "almost" compatible to Javascript JavaScriptͱͷޓ׵ੑ͸΄΅ສશ - bit-size in number types - runtime semantics in exceptions - difference of regex defs

Slide 12

Slide 12 text

2. Type definition can be applied by using TypeScript ܕఆٛ΋TypeScript͔ΒಋೖՄೳ sjrd/scala-js-ts-importer

Slide 13

Slide 13 text

3. fast compile ߴ଎ͳίϯύΠϧ 1-2 seconds even when optimized fullOptJS is used

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

5. supports SourceMap SourceMapαϙʔτ

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

4. difficult to change if html was embedded to code ίʔυʹhtmlΛຒΊࠐΉͱUIมߋʹऑ͍

Slide 22

Slide 22 text

5. compatibility/ability to track the latest version between other JavaScript libraries JavaScriptϥΠϒϥϦͱͷޓ׵ੑɺ࠷৽൛΁ͷ௥ैੑ

Slide 23

Slide 23 text

6. debugging cost on browsers ϒϥ΢β্Ͱͷσόοάίετ

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Javascript should covers UI JavaScriptͰUIΛ࣮૷

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

Pros ར఺

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

2. we can develop in Scala.js similar to usual development in Scala ௨ৗͷScala։ൃͱಉ͡Α͏ʹScala.jsͰ։ൃͰ͖Δ

Slide 33

Slide 33 text

3. flexibility of implementing UI UI࣮૷ͷࣗ༝౓্͕͕Δ

Slide 34

Slide 34 text

Cons ܽ఺

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

Is this really achievable? ࣮ݱՄೳʁ

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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