top | item 16354728

(no title)

gmartres | 8 years ago

> Is there a runtime lib? That includes e.g. Scala collections for the browser for example?

Pretty much all Scala code compiles with Scala.js, that includes the Scala standard library, as well as part of the Java standard library that has been reimplemented in Scala.

> How many kilobytes?

Scala.js does whole program optimization and dead code elimination, so there's not a single number that can be given here, you pay for what you use.

discuss

order

virtualwhys|8 years ago

> so there's not a single number that can be given here, you pay for what you use.

While true, in practice as soon as you use, for example, `List`, `Map`, and `Option`, along with various basic collection operations (`flatMap`, `map`, `zip`, ...) you've pulled in basically the entire standard lib*

Wind up paying about a 160KB baseline "tax" to use Scala in the browser, which is well worth it considering that you can ditch jQuery and related plugins (DataTables, Validation, etc.), shedding far more weight than Scala.js in the process. I find it to be a huge win, wish I could use it in current bloated Angular 5 + TypeScript project :\

* This is due in part to existing collections library that is not so amenable to dead code elimination (or at least google closure compiler can't track the full reach of CanBuildFrom's tentacles :)) Maybe this will change in Scala 2.13 collections overhaul, have my doubts, doesn't sound like the new design is radically different than the current one.