Dotty: exploring the future of scala
Dmitry Petrashko
Dotty?
- a new compiler for a Scala-like language
- developed at LAMP EPFL
- is currently not ready for production use
- some of the new technologies explored in this project will find their way into future versions of Scala
About me:
- https://github.com/darkdimius/
- doing PhD at EPFL
- previously worked on ScalaBlitz
- since March 2014 year working on Dotty.
Dotty contributor stats:
git ls-tree -r -z --name-only HEAD -- |egrep -z -Z -E '\.(scala)$'\
| xargs -0 -n1 git blame --line-porcelain |grep "^author "|sort|uniq -c|sort -nr
author | commits | additions | deletions | blame lines |
Martin Odersky | 2,280 | 146,133 | 85,391 | 57,284 |
Dmitry Petrashko | 628 | 158,249 | 50,201 | 83,929 |
Samuel Gruetter | 19 | 62,324 | 12,510 | 36,615 |
Ondrej Lhotak | 29 | 2,009 | 340 | 1,874 |
Guillaume Martres | 77 | 2,197 | 1,190 | 1,171 |
Vera Salvisberg | 17 | 1,109 | 364 | 819 |
Jason Zaugg | 16 | 213 | 149 | 153 |
Alexander Myltsev | 5 | 275 | 65 | 144 |
Vlad Ureche | 13 | 255 | 77 | 51 |
Talk Structure
- Part 1: What dotty is expected to bring to the table
- Language:
- Union(|) and Intersection(&) Types
- SIP-23: Literal-based Singleton Types
- SIP-24: Repeated By Name Parameters
- SIP-25: Trait Parameters
- SIP-20: Improved Lazy Vals Initialization
- Deprecations
- Ecosystem:
- Tasty
- scala.meta
- Linker
- Compilation speed
Talk Structure
- Part 2: Internals
- Denotations
- Denotation Transformers
- Mini-phases
- Tree Checkers and postconditions
Intersection(&) types
what is the difference?
with
is ordered, &
is not
A with B is different from B with A. & is not
Ecosystem: Binary compatibility
Ecosystem: Binary compatibility
Ecosystem: Binary compatibility
Ecosystem: Binary compatibility
Developing a library,
you need to consider publishing for
(2.10, 2.11, 2.12) x (java6, java8, JS) x (Typesafe, Typelevel)
Why???
This should not bother developers!!!
Ecosystem: Tasty
Ecosystem: TASTY
- Allows to get scala source from compiled classfiles
- Is not vulnerable to changes in implicit resolution
- No need to push multiple artifacts to maven. Dotty can recompile from TASTY
Ecosystem: ScalaMeta
- Metaprogramming done right
Previous project: Scalablitz
- Tunes collection operations for your use-case
- Gets ridiculous speedups(40x, 120x) for simple code, eg Array[Int].reduce(_+_)
- Less garbage allocated
- Better memory locality & cpu throuput utilization
Ecosystem: Linker
- Does the very same for any library
- Tunes library for your use-case
- Removes allocations, closures, virtual calls
- A smarter proguard
- Details: video, slides
Compilation speed
- Dotty has design decisions that allow to get substantial speedups
- MiniPhases and their fusion
- Info transformers
- We did not yet do any performance tuning, but
- Compiling Hello world takes 1.4 sec vs 1.6 sec by scalac
- Compiling Dotty itself takes 27 sec vs 42 sec by scalac
- Part 2: Internals
- Not a big cake
- Context instead of global mutable state
- Denotations
- Denotation Transformers
- Mini-phases
- Tree Checkers and postconditions
Denotations
Denotations
Macro Phases
Macro Phases
Macro Phases
- Every phase traverses a tree independently
- Reading cold data
- Creating new subtrees
- That live long and are promoted to OldGen of GC
Does LazyVals implement LazyVals?
If you want performance, you do not want many Macro phases
Why? Macro phases cost a lot
Half of phases do `something` additionally
Mini Phases
Mini Phases
Mini Phases
Mini Phases
- Phases share tree traversal
- Trees you are accessing are hot
- Trees die fast and do not get promoted to OldGen of GC