Key takeaways from the Scala days keynote

Ruurtjan Pul
bigdatarepublic
Published in
4 min readJun 26, 2017

There’s no Scala Days conference without a keynote of Martin Odersky himself. This year he spoke about his current work: Dotty. Dotty is the new Scala compiler that will be part of Scala 3. The first release candidate was released just hours before the keynote and comes with the compiler itself (dotc), a repl (doti), a doc tool (dotd) and an IDE. It implements the MS language server protocol, enabling it to serve several front ends: VS-Code and Emacs (IntelliJ support is in the works). With Dotty, IDE’s can use the regular compiler as the presentation compiler.

Scala/Dotty's road map from 2016 - 2019

Dotty is developed as a separate branch. It should release a stable 0.x in early 2018. The current rework on ctdlib collections will be part of 2.13 and dotty 0.1. Scala 3 is expected to release in 2019 or beyond. Dotty adopts the release train model with iterations of 6 weeks.

Why Dotty?

Three important language constructs are types, functions and objects. Most languages do two of the three. Scala should synthesize all three. For Scala, implicits are at the core of this: implicits are functions that pass around objects and is driven by typing.

Scalastic principles
Scalastic pragmatics

Context is what is outside of the project, but implicitly known. Scala implicits are the canonical way to represent context. Scala has pioneered the synthesis between types, functions and objects and a lot of languages are moving into this space. With the experience built in the past years, it’s a good time to rebuild the basics. This is backed up by the now stronger foundation in DOT calculus [paper].

Scala should balance between usability (for newcomers) simplicity (in the sense of small syntax and spec) and power. Dotty is an attempt to rebalance these things, to go back to the essence by dropping peripheral constructs and strengthening the core.

What has changed between Scala 2.12 and Dotty?

The four main changes are types, traits, enums and implicits.

Types
It’s currently hard to understand type checking rules and it has no good foundation. Dotty removes existential types and type projections. Both are unsound. They will be replaced by compound types with intersection types and union types. Also new in Dotty are type lambdas.

Traits
In Scala 2.x it’s not possible to pass parameters to traits. Early definitions are a common workaround, but will be removed in favor of trait parameters. The first class to extend a trait must implement it. Classes lower in hierarchy cannot. This guarantees trait parameters are implemented only once for each class.

Enums
Unlike most other languages, Scala has no enumeration language construct. With Dotty, enums can be defined. They will map transparently to classes, objects and vals. The compiler expands them to a class with a companion object.

Scala Dotty enumerations

Implicits
Implicits have caused much confusion by unintended converting types. In Dotty, implicit conversions can no longer be done with val’s. They must now be explicitly marked as an implicit conversion using ImplicitConverter. It can get tedious to declare implicits in large programs. This can be avoided with Dotty.

Closing remarks

Dotty is not yet ready for production. More features will be added and existing features may have their API’s changed before it’s released. If you want to try it out, now is a great moment to jump in.

BigData Republic provides Data Science as-a-Service. Our Big Data Engineers are experienced Scala developers. Interested in what we can do for you? Feel free to contact us.

--

--