The Things Scala js Does to Make Your Code Fast
summary
Scala.js compiles idiomatic Scala into JavaScript and an optimizer turns heavy abstractions into tight loops: a Range-based for becomes a raw while so performance matches hand-written code (non-optimized for was ~1.64 vs optimized ~0.12). Long arithmetic remains costly — about 100× slower for Longs — and requires library emulation. Collection map and lambdas get closure elimination and inlining so two chained maps run close to the manual double-while, while trait concrete methods use multi-inlining to remove bridge dispatch. Node.js and Closure Compiler appear in the toolchain; benchmarks are small, generated code is trusted.
AI-written summary · about
chapters (12)
- 0:00Intro
- 3:30Benchmarks
- 4:35generative code
- 9:50longs
- 13:15map
- 16:54speed test
- 23:55trades
- 26:48Optimization
- 28:34Results
- 33:18Closure Elimination
- 36:16Scala Optimizer
- 46:44Questions
related talks
42mScala.js Semantics - and how they support performance and JavaScript interop
50mIs scala code slow?
49mScala js: getting the best of JavaScript and Scala
29mExtreme JavaScript Performance
31mJavaScript Compilation Techniques or "Wasn't JavaScript supposed to be slow?"
27mJavaScript as a compilation target - Making it fast
29mJavaScript in JavaScript: Inception
42mFaster Scala Collections with Scalaxy/Streams!
