Dotty is coming:
how to prepare for migration
Dmitry Petrashko

Dotty?
- a new compiler for a Scala-like language
- developed at LAMP EPFL
- is currently not ready for production use
- will become Scala 3.0
About me:
- https://github.com/darkdimius/
- was first to join Martin in making Dotty in 2014
- together with Martin build foundations of Dotty
- started Dotty Linker & optimizer project
- currently writing thesis about Dotty architecture
Agenda
- Building our common future
- Maintaining our common past
- Binary compatibility. @stableABI
- Source compatibility. Scalafix
- Dotty Community build
Feature status:
Implemented:
- Fast compilation (phase fusion)
- Implicit awesomeness
- Union, intersection and literal singleton types
- Trait parameters
- @static methods and fields
- Non-blocking lazy vals
- Sbt incremental build
- Option-less pattern matching (based on name-based patmat)
- Multiversal equality
- Lifted restrictions on value classes
- Nice enumerations
Feature status:
Currently actively developed:
- Native HList & HMaps/Record types
- Local optimizations, based on Linker
- Whole program dead code elimination & optimizations, based on Linker
- phantom types
- Scala.Meta macros
- CBT support
A lot of new features are coming
Allowing:
- new ways to build library APIs
- new approaches to structure library components
- more efficient implementations of library internals
The future will arrive soon
This is the right moment to join us in building it.
It's important to maintain it
and build on it
Migration:
- how to try new features
- how to stay compatible across two versions of Scala
- how to make sure your code stays Dotty compatible.
Binary compatibility
- Dotty is a new major version of Scala compiler;
- Major Scala version have been incompatible with with previous versions;
- nevertheless, Dotty provides best-effort compatibility with 2.11.x;
- @stableABI SIP is intended to provide more guarantees;
@stableABI SIP:
- @tailrec-like annotation that will fail compilation if class may be incompatible across major versions;
- should be used together with MiMa;
- provides java-like binary compatibility guarantees;
- would allow to build libraries that could be used by all future Scala versions
- is a long-term "promise" given by compiler teams to community
Source compatibility:
Dotty is highly source-compatible with Scala 2.12, but there are differences:
- no procedure syntax
- thread-unsafe lazy vals by default
- explicit types are required for implicit members
- fixes to type inference
Try it out on your project
- add
"ch.epfl.lamp" % "sbt-dotty" % "0.1.0-RC2"
- add
"ch.epfl.scala" % "sbt-scalafix" % "0.3.2"
- run
scalafix; compile
Try it out on your project
Known caveats:
- no scala.reflect macro support
- only JVM currently, js & native will be available later
- standard library
- typelevel/algebra
- typelevel/squants
- ScalaTest
- ScalaCheck is on the way
Dotty is coming: how to prepare for migration
Dmitry Petrashko