Scala 2.13 overhauls collections, improves the standard library

Posted on 11-06-2019 , by: admin , in , 0 Comments

Scala, the functional and object-oriented programming language with JVM and JavaScript runtimes, is available in a new version. Scala 2.13 improves the standard library with an overhaul of collections, the addition of new classes and methods, and performance and stability improvements.

Collections in the standard library have been overhauled for performance, safety, and simplicity. Multiple improvements have been made to collections including:

  • Simpler method signatures. Transformation methods no longer take an implicit CanBuildFrom parameter. 
  • Simpler type hierarchy. Traversable and TraversableOnce have been deprecated to aliases for Iterable and IterableOnce
  • Parallel collections now are a separate module.
  • The Seq trait for sequences is now an alias for collection.immutable.Seq. Previously, it was a an alias for possibly mutable collection.Seq.
  • Simplified, workable views are featured, along with quicker HashMap/Set implementations.
  • Collection serialization has changed. Collections now use the serialization proxy pattern when possible.
  • SeqMap has been added as an abstraction type, with immutable.SeqMap providing immutable maps to maintain insertion order.

Also in the standard library, the Future capability is faster. Future represents a value that may or may not be currently available, or an exception if that value could not be made available. Extension methods for Java interoperability are now located in scala.jdk and explicit converters for Java are in scala.jdk.javaapi. The scala-java8-compat module Is now part of the standard library.

Other improvements in Scala 2.13:

  • The compiler promises to be 5% to 10% faster. It also features an improved optimizer and leverages deterministic output. The compiler will generate identical output for identical input in more cases, for reproducible builds. Operations on collections have been further optimized and inlining has been improved.
  • Literals for strings and integers now have associated types. Also, underscores now can be used as spacers.

Initially a JVM language, Scala has since added a runtime for JavaScript, with the introduction of Scala.js. You can find instructions for downloading Scala on the Scala website.