Scala 3 gets a makeover to be more your type


Scala 3 is out, bringing major changes to the JVM-compatible language but maintaining the same Application Binary Interface (ABI) as Scala 2.13 – this ensures that Scala 2.13 and Scala 3 class files can be loaded by the same JVM class loader.

Announced on the Scala blog, the release is described as “a game changer in terms of compatibility”, despite a range of new features.

Scala 3 is actually a complete overhaul of the Scala language, with many changes to the type system to make the language more principled. In particular, it introduces a new “quiet” syntax for control structures like if, while, and for, while implicits and their syntax have been heavily revised.

In fact, Scala 3 takes a different approach and focuses on intent rather than mechanism, according to the Scala team. This means that Scala 3 offers multiple tailored language features, allowing programmers to directly express their intent. Using clauses allows developers to abstract over information that is available in the calling context, for example. Clauses can now be specified by type, an improvement over Scala 2 implicits.

Meanwhile, given instances allow developers to define the canonical value of a certain type, making coding with type-classes more straightforward. Also in Scala 3, extension methods are now directly built into the language, whereas in Scala 2, extension methods had to be encoded using implicit conversions or implicit classes.

As well as improved type inference, the Scala 3 type system has a number of new features such as enumerations to express algebraic data types, opaque type aliases which supersede value classes and allow you to set up an abstraction barrier without causing additional overheads, polymorphic function types, type lambdas and type level functions that can be passed as type arguments without requiring an auxiliary type definition.

One thing that has changed completely in Scala 3 is macros. According to the Scala team, the metaprogramming API of Scala 3 is designed in layers to support different levels of use-cases. This means that macros can be defined in terms of a high-level API of quoted expressions that allows simple construction and deconstruction of program expressions, or in terms of the more low-level reflection API that provides a more complex and comprehensive view on the structure of the code.

Following this 3.0.0 release, the Scala team said it intends to continue issuing releases every six weeks. A stable 3.0.x release will be preceded with 3.0.x-RC1 release candidate 6 weeks prior to such a stable release. New language features and standard library APIs will appear in future minor versions. However, the Scala team says that minor releases will not break backward compatibility.