Scala 2.13 is here with overhauled collections, improved compiler performance, and more!

2 min read

Last week, the Scala team announced the release of Scala 2.13. This release brings a number of improvements including overhauled standard library collections, a 5-10% faster compiler, and more.

Overhauled standard library collections

The major highlight of Scala 2.13 is standard library collections that are now better in simplicity, performance, and safety departments as compared to previous versions.  Some of the important changes made in collections include:

Simpler method signatures

The implicit CanBuildFrom parameter was one of the most powerful abstractions in the collections library. However, it used to make method signatures too difficult to understand. Beginning this release, transformation methods will no longer take an implicit ‘CanBuildFrom’ parameter making the resulting code simpler and easier to understand.

Simpler type hierarchy

The package scala.collection.parallel is now a part of the Scala standard module. This module will now come as a separate JAR that you can omit from your project if it does not uses parallel collections. Additionally, Traversable and TraversableOnce are now deprecated.

New concrete collections

  • The Stream collection is now replaced by LazyList that evaluates elements in order and only when needed.
  • A new mutable.CollisionProofHashMap collection is introduced that implements mutable maps using a hashtable with red-black trees in the buckets. This provides good performance even in worst-case scenarios on hash collisions.
  • The mutable.ArrayDeque collection is added, which is a double-ended queue that internally uses a resizable circular buffer.

Improved Concurrency

In Scala 2.13, Futures are “internally redesigned” to ensure it provides expected behavior in a broader set of failures. The updated Futures will also provide a foundation for increased performance and support more robust applications.

Changes in the language

The updates in language include the introduction of literal-based singleton types, partial unification on by default, and by-name method arguments extended to support both implicit and explicit parameters.

Compiler updates

The compiler will now be able to perform a deterministic and reproducible compilation. This essentially means that it will be able to generate identical output for identical input in more cases. Also, operations on collections and arrays are now optimized making the compiler 5-10% better compared to Scala 2.12.

These were some of the exciting updates in Scala 2.13. For a detailed list, check out the official release notes.

Read Next

How to set up the Scala Plugin in IntelliJ IDE [Tutorial]

Understanding functional reactive programming in Scala [Tutorial]

Classifying flowers in Iris Dataset using Scala [Tutorial]