Scala 2.13 Updates For Lightbend Platform Technologies
Lightbend, EPFL, and the Scala Center recently released Scala 2.13. As this release paves the way for Scala 3 later in 2020, the Scala team at Lightbend took the opportunity to answer a few questions about why this release is important, what improvements were made, and how to contribute to future versions of Scala--no matter how experienced you are!
Q: What were the major improvements in Scala 2.13?
We focused on improving the Collections in the Scala standard library. They have been overhauled for simplicity, performance, and safety. From a user’s perspective, the Collections API is mostly (source) compatible with Scala 2.12. From the outside, the main difference is that we now use regular method overloading instead of the CanBuildFrom pattern, which was often cited as a pain point with the old collections. Internally, the implementation has been simplified for easier maintenance and optimized for performance.
Also in the standard library, Future is faster and more robust, and many small convenience methods and classes were added. We also removed any functionality that had been deprecated for two major releases (ca 5 years).
The compiler is about 10% faster, while also offering improved support for repeatable builds under changing build conditions, i.e. producing identical output regardless of the ordering of source files, or whether you’re compiling all sources together or separately using class files.
Q: What did you feel was the biggest challenge in this release?
The collections are core to the Scala user experience, and the rework was subject to many conflicting requirements: maintaining compatibility while completely reworking the internals, improving performance while providing richer, higher-level abstractions that can underpin both strict and lazy collections. We also had to improve the compiler to enable the new design.
This effort was only possible thanks to the successful collaboration between Lightbend, EPFL, Scala Center and the many active contributors in the Scala Community. We used the Scala Community build to validate the design, measure its impact in terms of breaking changes and even to prepare upstream pull requests to help minimize the impact on the OSS ecosystem.
Q: What was the most significant bugfix that feels good to have finally squashed?
For years, we’ve been uneasy with certain unexplained “optimizations” in refchecks -- the part of the compiler that ensures there are no missing or incorrect overrides. It turned out that illegal overrides had actually crept into the collections internals because of these optimizations – which coincidentally had been added the last time we reworked the collections, almost 10 years ago. It felt good to finally remove those shortcuts, although it was also a bit scary to consider how much they had inadvertently been exploited in the meantime... (It did cause a few regressions in Java interop, where overriding rules are slightly different from Scala. We’re working on fixing those for 2.13.1.)
Q: What Lightbend Platform technologies does this upgrade?
Scala 2.13 support is currently expanding across many of the components of Lightbend Platform. Here are some examples:
Lightbend Telemetry 2.11.3 supports Scala 2.13 instrumentation for the new Future implementation, and supports Akka, Akka HTTP, and Play Framework on Scala 2.13: https://developer.lightbend.com/docs/telemetry/current/home.html
Fortify SCA for Scala recently added Scala 2.13 support: https://developer.lightbend.com/docs/fortify/current/
Akka has published Scala 2.13 artifacts for several projects: https://akka.io/blog/news/2019/06/11/scala-2.13-landed-in-akka
The Alpakka Kafka connector is published for Scala 2.13, with most other Alpakka connectors following soon after reconciling dependencies with other libraries to be published for Scala 2.13: https://doc.akka.io/docs/alpakka-kafka/current/
Play Framework 2.7.3 is released with binaries for Scala 2.13: https://discuss.lightbend.com/t/play-2-7-3-released/4459
Lagom Framework 1.6 will be released in Oct 2019 and will fully support Scala 2.13.
Q: What is expected in the next release, how can folks contribute?
Scala 2.14 will be all about smoothing the migration path to Scala 3, which will go into feature freeze later this year. To increase the shared subset of features that are available to anyone who wants to cross-build between 2 and 3, we intend to backport some of the key Scala 3 features to Scala 2.14: trait parameters, top-level definitions and enums. Since the first few releases of the Scala 3.x series will support most non-deprecated Scala 2.14 features, we are also planning to remove some already deprecated features that we would like to remove as quickly as possible (procedure syntax, early initializers).
A great way to start contributing is by reviewing pull requests: asking questions is a great way to make sure the changes are maintainable, while also improving your own understanding of the code base (VIDEO). We’re always grateful for improvement to our documentation. If you’re interested in fixing bugs, we curate a list of reasonably sized issues to get you started. For larger contributions, it’s best to discuss them first on a ticket, so we can make sure we’re all moving in the same direction.