back

by wiradikusuma·4y ago·view on hn ↗
How's the compilation speed for compiling Scala to JS? Eons ago I used Scala for Android development. Let say it was a traumatic experience, so now I use Scala exclusively at the server side.
1 comments
From saving the file until the browser refreshes it usually only takes a few seconds. Especially if the compiler JVM is warm.
how does it compare with typescript?
Typescript's main advantage is convenience and familiarity to JS devs. With typescript you just put type hints on your good old javascript and you get to keep using all your javascript coding patterns.

This comes at a cost of unsafety / unsoundness which is a tradeoff by design. Scala's type system is infinitely more robust. I use Typescript occasionally with all the strictest flags, and yet it allows invalid code that shouldn't compile, all the damn time. Such unreliable type checking is all but worthless to me personally.

Scala is hands down better than Typescript for functional programming. It was actually designed for that from the start. But it's not religious about it either, its OOP features are rich and integrate with FP features very nicely.

Scala.js community and ecosystem is small compared to Typescript, but very diverse and passionate. The mechanism of interfacing with JS is in principle similar to Typescript, but in practice takes a bit more setup.

Also with Scala/Scala.js, you get to a whole other level of productivity when you use the same language on both the client and the server.

I meant in regards to compile times

I'm intimately familiar with both languages but thanks for the run down

Incremental compilation is pretty fast on Scala.js – it usually takes just a few seconds for me, about half of which is usually webpack bundling. Although if you make a code change that affects many modules of your app, it will take a bit more, but still very reasonable.

I haven't had a chance to compare speeds apples-to-apples, but I expect Typescript incremental compilation to be faster than Scala.js. Though, to me this metric has stopped being relevant because using a type safe language I stopped looking at my changes in the browser every minute, like I used to do when I was writing frontends in Javascript.

LESS/CSS compilation is the only part where I really care about speed since pixel pushing always needs trial and error, so I set it up to be separate from Scala.js compilation, and it's as fast as it would be in JS world.