4 ms·
I had no idea this was a thing! and I learned Scala from Prof Odersky himself ;-) What are the selling points of Scala.js vs modern JavaScript/TypeScript?
by MasterScrat 4y ago
I had no idea this was a thing! and I learned Scala from Prof Odersky himself ;-)
What are the selling points of Scala.js vs modern JavaScript/TypeScript?
- sjrd 4y agoProbably all the same selling points that Scala/JVM has over Java or Kotlin. The main one would be favoring a coding style with immutable data, only reaching for mutability when necessary. If you like that style, Scala.js will help you write in that style. See also one of my other answers with some more comparisons.
- nikitaga 4y agoTypescript is not actually very type safe, and although they sometimes make small improvements on that front, the unsafety is fundamentally very much by design, they prioritize supporting all the dynamic Javascript idioms over type system soundness, it's even in their docs somewhere. Scala is a very nice and expressive language with a much safer type system. It lets you program in a very reasonable mix of FP and OOP without going to the extremes of either approach. You're not beholden to weird Javascript idioms yet you can still easily use JS libraries (we have ScalablyTyped which is like Typescript's DefinitelyTyped). Typescript is generally well loved partly because for many Javascript developers it is their first and only statically typed language, so they tend to attribute the benefits of static typing to Typescript, and attribute the problems specific to Typescript to static typing in general. This makes it hard to sell Scala.js to this audience, but I still encourage JS devs to try other statically typed languages, maybe you'll like them much more.
- AlexITC 4y ago> This makes it hard to sell Scala.js to this audience, but I still encourage JS devs to try other statically typed languages, maybe you'll like them much more. Actually, I have had some success onboarding js devs into sjs, until now, all of them have mentioned that it is hard to go back to js/ts because the type-safety just can't be compared (I even presented this at a conference last December). These are some comparisons on js vs sjs code on top of react (js on the left, sjs on the right): - Hello World: https://pbs.twimg.com/media/FngeaoraAAAr2r0?format=jpg&name=900x900 https://pbs.twimg.com/media/FngeaoraAAAr2r0?format=jpg&name=... - Timer: https://pbs.twimg.com/media/FnlL1PjaMAEL-zJ?format=jpg&name=small https://pbs.twimg.com/media/FnlL1PjaMAEL-zJ?format=jpg&name=... - ReCAPTCHA usage: https://pbs.twimg.com/media/FnvY_hAagAIjWF5?format=jpg&name=900x900 https://pbs.twimg.com/media/FnvY_hAagAIjWF5?format=jpg&name=...