Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 24: The Scala Collections API > 24.1 Mutable and immutable collections - Pg. 498

C HAPTER 24 · The Scala Collections API majority of errors you might make are caught at compile-time. The reason is that (1) the collection operations themselves are heavily used and therefore well tested. (2) the usages of the collection operation make inputs and output explicit as function parameters and results. (3) These explicit inputs and outputs are subject to static type checking. The bottom line is that the large majority of misuses will manifest themselves as type errors. It's not at all uncommon to have programs of several hundred lines run at first try. Fast: Collection operations are tuned and optimized in the libraries. As a re- sult, using collections is typically quite efficient. You might be able to do a little bit better with carefully hand-tuned data structures and oper- ations, but you might also do a lot worse by making some suboptimal implementation decisions along the way. What's more, collections are currently being adapted to parallel execution on multi-cores. Paral- lel collections will support the same operations as sequential ones, so no new operations need to be learned and no code needs to be rewrit- ten. You will be able to turn a sequential collection into a parallel one simply by invoking the par method.