SlideShare a Scribd company logo
1 of 48
Download to read offline
Preparing For Scala 3
Adrian Moors
Martin Odersky
Scala Days Berlin
April 2018
Roadmap (from previous years)
Scala 2.12
Scala 2.13
Scala 3.0
TASTY,
middle end?
stdlib
collections
Dotty 0.1
Dotty 0.x releases
2016
backend, classpath handling
Scala 2.14
2017
2018
This is open source work, depends on community’s contributions.
à Roadmap is tentative, no promises:
“MVP” = minimal
viable
prototype
Scala 2.15?
migration
Roadmap (now)
Scala 2.12
Scala 2.13
Scala 3.0
TASTY,
middle end?
stdlib
collections
Dotty 0.1
Dotty 0.x releases
2016
backend, classpath handling
Scala 2.14
2017
2018
This is open source work, depends on community’s contributions.
à Roadmap has held up pretty well so far!
“MVP” = minimal
viable
prototype
migration Early 2020
Early 2020
License Change
http://scala-lang.org/news/license-change.html
BSD 3 à Apache v2.0
Concerns? let us know by Aug 10
Developer Survey
http://scala-lang.org/news/survey-2018.html
Would love to hear from you!
Takes 15 min
Why Scala 3 ?
The Essence of Scala:
Fusion of functional and
object-oriented programming
The Essence of Scala:
Fusion of functional and
object-oriented programming
in a typed setting
• functions for the logic
• objects for the modularity
Success!
Starting from a statically typed OO core
language, Scala pioneered
closures, function types, expression orientation,
tuples, local type inference, pattern matching,
traits, lazy vals, by-name parameters, x:T syntax,
dependent types, implicit parameters, and more
Many other languages followed suit by
adopting some of these features:
C#, Kotlin, Swift, Java, …
🎉
Derailing It
• Scala as a worse Haskell for the JVM
• A better Java, without Scala’s deep parts
Both take one half of Scala’s features, but ignore
the synthesis
Derailing It
Haskalator: Scala as a worse Haskell for the JVM
• Haskell is a great language
• But Scala is not a good basis for emulating all
Haskell patterns
• If you choose to ignore Scala’s OOP parts,
there’s little point in using it at all!
Derailing It
A better Java, without Scala’s deep parts
• new languages such as Kotlin, Swift,
• improved languages such as C#, Java
• trade abstraction & composition for more ad-
hoc features,
• avoid the more esoteric FP parts by making it
less pleasant to express them.
à larger language, simpler programs?
0
200
400
600
800
1000
1200
1400
1600
python haskell scala kotlin swift java8 c++ csharp
Grammar size in lines
Grammar size in lines
The Way Forward
We believe Scala’s fusion of FP and OOP is
still the most promising way forward for
general purpose software development.
But…
The Way Forward
But there are lots of things we have learned
since the inception of Scala, including
1. how to be pure without sacrificing
simplicity and performance
2. how to do meta programming, safely
3. how to cut down on boilerplate for new
idioms
The Way Forward
Incorporate these new techniques in the
language, to make it simpler, more focused,
and more pleasant to use.
Realizing Scala’s Potential
• become more opinionated
• simplify
• eliminate inconsistencies and puzzlers
• build on strong foundations
• consolidate language constructs to improve
consistency
safety
ergonomics
performance
Consistency
Improve orthogonality and eliminate restrictions:
• Intersection types A & B
• Union types A | B
• Implicit function types implicit A => B
• Dependent function types (x: A) => x.B
• Trait parameters trait T(x: A)
• Generic tuples (a, b, c)
== (a, (b, (c, ()))
Ergonomics
Make code readable and concise
• Enums enum Color {
case Red, Green, Blue
}
• Type lambdas [X] => F[X]
Safety
Enable precise domain modeling and safe refactoring.
• Multiversal equality List(“a”) == “b”
• Restrict implicit conversions
Also planned:
• Null safety String | Null
• Effect capabilities
Performance
Make abstractions cheaper:
• Opaque types opaque type A = B
• Erased parameters def f(erased x: A =:= B)
Removed
• existential types using forSome
• procedure syntax
• early initiliazers
• XML literals
• limit 22
• automatic () insertion
• weak conformance
• auto-tupling
• multi-parameter infix operators
Implicit Improvements
Implicits turned out to be where Scala innovated most.
They can be both a
blessing and a curse.
Goal for Scala 3:
Fewer curses!
à Simplicitly,
POPL 2018
so far:
Implicit Conversions
Implicit Parameters
in the future:
Implicit Conversions
Implicit Parameters
Cutting-down on implicit conversions
Extension clauses can subsume most valid use cases:
case class Circle(x: Double, y: Double, radius: Double)
extension CircleOps for Circle {
def circumference = radius * Pi * 2
}
instead of
implicit class CircleOps(circle: Circle)
extends AnyVal {
def circumference = circle.radius * Pi * 2
}
Cutting-down on implicit conversions
Most other uses (not just definitions!) require a
language import:
import language.implicitConversions
implicit def str2int(x: String) = x.toInt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import language.implicitConversions
val x: Int = “123”
*exempted are only conversions co-defined with their target type
Making Implicit Parameters more Useful
Multiple implicit
clauses
Explicit
applications
Implicit function
types
def f(implicit x: A)
(y: B)
(implicit z: C) = …
f.explicitly(a)(b)
implicit A => B
Implicit Function Types:
get purity without sacrificing
simplicity and performance.
Tooling
So far, we have:
• a new compiler: dotc
• rich IDE support through LSP with direct
support for VS Code.
• REPL
• Doc-tool
Most tooling is built around Tasty
Tasty
Typed abstract syntax trees
• serialization format for Scala
• complete position and type information
• all implicits are expanded out
• surprisingly compact (~ same size as
source)
The Tasty Vision
Tasty
.scala (2.x)
.scala (3.x)
.class (Java 8)
.js
.class (Java 11)
.out
macros
analyzers
optimizers
IDE
LSP
Tasty Use Cases
• Separate compilation
• Language servers for IDEs (via LSP)
• Macros
• Cross-building
à escape the curse of binary compatibility
Meta Programming, So Far
• Def macros (experimental),
macro paradise (plugin).
- Both are thin veneers around nsc.
• Scala Meta: External tools that analyze
and transform programs.
Principled Meta Programming
2 + 2 fundamental operators:
‘( … ) (quote)
~(...) (splice)
run
inline
Quote, splice + inline : macros
Quote, splice + run : staging
Principled Meta Programming
T Expr[T]
Restriction: Can’t look inside an Expr.
splice ~(…)
quote ‘(…)
Principled Meta Programming
T Expr[T] tasty.Tree
Solution: Bijection between Expr[T] (high-level)
and tasty.Tree (low-level)
reflect
reifysplice ~(…)
quote ‘(…)
The Tasty Vision
Tasty
.scala (2.x)
.scala (3.x)
.class (Java 8)
.js
.class (Java 11)
.out
macros
analyzers
optimizers
IDE
LSP
New Macros are “Blackbox”
They get expanded after type checking.
à Program must typecheck before
macros are expanded
à Macros always work on typed trees
à Hygienic by definition
à Drastically reduces # things that can
go wrong
Language-Level Solutions for
Lazy implicits ✔
Type lambdas ✔
Context injection ✔
Typeclass derivation (still to do)
Typelevel functions (to be explored)
Migration
• Despite many differences, Scala 2 and 3 are
still fundamentally the same language
• Source compatibility for common subset.
• Rewrite tools can handle much of the rest
(macros are the big exception here).
• Situation better than for Python 2 vs 3 because
of static typing & binary compatibility.
Binary Compatibility
today:
Dotty can link with
Scala-2.12 class files.
Scala 2 module
Dotty module
Binary Compatibility
today:
Dotty can link with
Scala-2.12 class files.
planned:
Two way compatibility
using Tasty as common
intermediate format.
Scala 2 module
Scala 3 module
Scala 2 module
Scala 3 module
Roadmap
2018 Flesh out design Dotty 0.x
Get feedback
Refinements
2019, first half -------------- Feature freeze ---------------
Scala 3
Stabilization dev previews
2020, first half Scala 3.0
Stability
So far:
• Most Scala 2 regression tests are in the Scala 3
test suite.
• Community build for core libraries and tools.
• All tools are built using Scala 2 first, and then
again with dotc.
Stability
Planned:
• Once there are developer previews, ensure that
core projects are published for Scala 3.
• Use dotc itself as the bootstrap root.
à“eat our own dogfood”
should use Scala 3 features in our own tools.
Try It Out Today!
dotty.epfl.ch
New versions are released every 6 weeks.
Questions,
Suggestions,
Concerns?
Talk to us anytime.
Also, there’s a panel where we will
respond to questions at the end of the
conference.
Plus, a contributors workshop on Friday.
Talk to Heather if you want to go.

More Related Content

What's hot

ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022Alexander Ioffe
 
Functional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 WayFunctional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 WayDebasish Ghosh
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Philip Schwarz
 
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldJorge Vásquez
 
Functors, Applicatives and Monads In Scala
Functors, Applicatives and Monads In ScalaFunctors, Applicatives and Monads In Scala
Functors, Applicatives and Monads In ScalaKnoldus Inc.
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...Philip Schwarz
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!MeriamLachkar1
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
 
Map, Filter and Reduce In Python
Map, Filter and Reduce In PythonMap, Filter and Reduce In Python
Map, Filter and Reduce In PythonSimplilearn
 
Reactive Microservice Architecture with Groovy and Grails
Reactive Microservice Architecture with Groovy and GrailsReactive Microservice Architecture with Groovy and Grails
Reactive Microservice Architecture with Groovy and GrailsSteve Pember
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Philip Schwarz
 
How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021
How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021
How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021Natan Silnitsky
 
Why functional programming and category theory strongly matters
Why functional programming and category theory strongly mattersWhy functional programming and category theory strongly matters
Why functional programming and category theory strongly mattersPiotr Paradziński
 
Category Theory in 10 Minutes
Category Theory in 10 MinutesCategory Theory in 10 Minutes
Category Theory in 10 MinutesJordan Parmer
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaJorge Vásquez
 
Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Jorge Vásquez
 
What's new in Scala 2.13?
What's new in Scala 2.13?What's new in Scala 2.13?
What's new in Scala 2.13?Hermann Hueck
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
 

What's hot (20)

ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022
 
Functional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 WayFunctional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 Way
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
 
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorld
 
Functors, Applicatives and Monads In Scala
Functors, Applicatives and Monads In ScalaFunctors, Applicatives and Monads In Scala
Functors, Applicatives and Monads In Scala
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in Scala
 
Map, Filter and Reduce In Python
Map, Filter and Reduce In PythonMap, Filter and Reduce In Python
Map, Filter and Reduce In Python
 
Reactive Microservice Architecture with Groovy and Grails
Reactive Microservice Architecture with Groovy and GrailsReactive Microservice Architecture with Groovy and Grails
Reactive Microservice Architecture with Groovy and Grails
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
 
How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021
How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021
How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021
 
Java Quiz Questions
Java Quiz QuestionsJava Quiz Questions
Java Quiz Questions
 
Why functional programming and category theory strongly matters
Why functional programming and category theory strongly mattersWhy functional programming and category theory strongly matters
Why functional programming and category theory strongly matters
 
Category Theory in 10 Minutes
Category Theory in 10 MinutesCategory Theory in 10 Minutes
Category Theory in 10 Minutes
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
 
Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0
 
What's new in Scala 2.13?
What's new in Scala 2.13?What's new in Scala 2.13?
What's new in Scala 2.13?
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
 
Applicative Functor
Applicative FunctorApplicative Functor
Applicative Functor
 

Similar to Preparing for Scala 3

Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaScala Italy
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Codemotion
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Codemotion
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaDmitry Buzdin
 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark Summit
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論scalaconfjp
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinayViplav Jain
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San FranciscoMartin Odersky
 
Realizing the Promise of Portable Data Processing with Apache Beam
Realizing the Promise of Portable Data Processing with Apache BeamRealizing the Promise of Portable Data Processing with Apache Beam
Realizing the Promise of Portable Data Processing with Apache BeamDataWorks Summit
 
Realizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache BeamRealizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache BeamDataWorks Summit
 
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...Codemotion
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumNgoc Dao
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNManish Pandit
 
Migrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to GradleMigrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to Gradle🎤 Hanno Embregts 🎸
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMarakana Inc.
 

Similar to Preparing for Scala 3 (20)

Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
 
Scalax
ScalaxScalax
Scalax
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin Odersky
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
 
Realizing the Promise of Portable Data Processing with Apache Beam
Realizing the Promise of Portable Data Processing with Apache BeamRealizing the Promise of Portable Data Processing with Apache Beam
Realizing the Promise of Portable Data Processing with Apache Beam
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 
Realizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache BeamRealizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache Beam
 
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
 
Migrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to GradleMigrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to Gradle
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 

More from Martin Odersky

What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave ImplicitMartin Odersky
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave ImplicitMartin Odersky
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyMartin Odersky
 
Compilers Are Databases
Compilers Are DatabasesCompilers Are Databases
Compilers Are DatabasesMartin Odersky
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slidesMartin Odersky
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleMartin Odersky
 
Scala eXchange opening
Scala eXchange openingScala eXchange opening
Scala eXchange openingMartin Odersky
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 

More from Martin Odersky (14)

scalar.pdf
scalar.pdfscalar.pdf
scalar.pdf
 
Simplicitly
SimplicitlySimplicitly
Simplicitly
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
From DOT to Dotty
From DOT to DottyFrom DOT to Dotty
From DOT to Dotty
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in Dotty
 
Compilers Are Databases
Compilers Are DatabasesCompilers Are Databases
Compilers Are Databases
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Flatmap
FlatmapFlatmap
Flatmap
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slides
 
Devoxx
DevoxxDevoxx
Devoxx
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
 
Scala eXchange opening
Scala eXchange openingScala eXchange opening
Scala eXchange opening
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Preparing for Scala 3

  • 1. Preparing For Scala 3 Adrian Moors Martin Odersky Scala Days Berlin April 2018
  • 2. Roadmap (from previous years) Scala 2.12 Scala 2.13 Scala 3.0 TASTY, middle end? stdlib collections Dotty 0.1 Dotty 0.x releases 2016 backend, classpath handling Scala 2.14 2017 2018 This is open source work, depends on community’s contributions. à Roadmap is tentative, no promises: “MVP” = minimal viable prototype Scala 2.15? migration
  • 3. Roadmap (now) Scala 2.12 Scala 2.13 Scala 3.0 TASTY, middle end? stdlib collections Dotty 0.1 Dotty 0.x releases 2016 backend, classpath handling Scala 2.14 2017 2018 This is open source work, depends on community’s contributions. à Roadmap has held up pretty well so far! “MVP” = minimal viable prototype migration Early 2020 Early 2020
  • 4. License Change http://scala-lang.org/news/license-change.html BSD 3 à Apache v2.0 Concerns? let us know by Aug 10
  • 7. The Essence of Scala: Fusion of functional and object-oriented programming
  • 8. The Essence of Scala: Fusion of functional and object-oriented programming in a typed setting • functions for the logic • objects for the modularity
  • 9. Success! Starting from a statically typed OO core language, Scala pioneered closures, function types, expression orientation, tuples, local type inference, pattern matching, traits, lazy vals, by-name parameters, x:T syntax, dependent types, implicit parameters, and more Many other languages followed suit by adopting some of these features: C#, Kotlin, Swift, Java, … 🎉
  • 10. Derailing It • Scala as a worse Haskell for the JVM • A better Java, without Scala’s deep parts Both take one half of Scala’s features, but ignore the synthesis
  • 11. Derailing It Haskalator: Scala as a worse Haskell for the JVM • Haskell is a great language • But Scala is not a good basis for emulating all Haskell patterns • If you choose to ignore Scala’s OOP parts, there’s little point in using it at all!
  • 12. Derailing It A better Java, without Scala’s deep parts • new languages such as Kotlin, Swift, • improved languages such as C#, Java • trade abstraction & composition for more ad- hoc features, • avoid the more esoteric FP parts by making it less pleasant to express them. à larger language, simpler programs?
  • 13. 0 200 400 600 800 1000 1200 1400 1600 python haskell scala kotlin swift java8 c++ csharp Grammar size in lines Grammar size in lines
  • 14. The Way Forward We believe Scala’s fusion of FP and OOP is still the most promising way forward for general purpose software development. But…
  • 15. The Way Forward But there are lots of things we have learned since the inception of Scala, including 1. how to be pure without sacrificing simplicity and performance 2. how to do meta programming, safely 3. how to cut down on boilerplate for new idioms
  • 16. The Way Forward Incorporate these new techniques in the language, to make it simpler, more focused, and more pleasant to use.
  • 17. Realizing Scala’s Potential • become more opinionated • simplify • eliminate inconsistencies and puzzlers • build on strong foundations • consolidate language constructs to improve consistency safety ergonomics performance
  • 18. Consistency Improve orthogonality and eliminate restrictions: • Intersection types A & B • Union types A | B • Implicit function types implicit A => B • Dependent function types (x: A) => x.B • Trait parameters trait T(x: A) • Generic tuples (a, b, c) == (a, (b, (c, ()))
  • 19. Ergonomics Make code readable and concise • Enums enum Color { case Red, Green, Blue } • Type lambdas [X] => F[X]
  • 20. Safety Enable precise domain modeling and safe refactoring. • Multiversal equality List(“a”) == “b” • Restrict implicit conversions Also planned: • Null safety String | Null • Effect capabilities
  • 21. Performance Make abstractions cheaper: • Opaque types opaque type A = B • Erased parameters def f(erased x: A =:= B)
  • 22. Removed • existential types using forSome • procedure syntax • early initiliazers • XML literals • limit 22 • automatic () insertion • weak conformance • auto-tupling • multi-parameter infix operators
  • 23. Implicit Improvements Implicits turned out to be where Scala innovated most. They can be both a blessing and a curse. Goal for Scala 3: Fewer curses! à Simplicitly, POPL 2018
  • 25. in the future: Implicit Conversions Implicit Parameters
  • 26. Cutting-down on implicit conversions Extension clauses can subsume most valid use cases: case class Circle(x: Double, y: Double, radius: Double) extension CircleOps for Circle { def circumference = radius * Pi * 2 } instead of implicit class CircleOps(circle: Circle) extends AnyVal { def circumference = circle.radius * Pi * 2 }
  • 27. Cutting-down on implicit conversions Most other uses (not just definitions!) require a language import: import language.implicitConversions implicit def str2int(x: String) = x.toInt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import language.implicitConversions val x: Int = “123” *exempted are only conversions co-defined with their target type
  • 28. Making Implicit Parameters more Useful Multiple implicit clauses Explicit applications Implicit function types def f(implicit x: A) (y: B) (implicit z: C) = … f.explicitly(a)(b) implicit A => B
  • 29. Implicit Function Types: get purity without sacrificing simplicity and performance.
  • 30. Tooling So far, we have: • a new compiler: dotc • rich IDE support through LSP with direct support for VS Code. • REPL • Doc-tool Most tooling is built around Tasty
  • 31. Tasty Typed abstract syntax trees • serialization format for Scala • complete position and type information • all implicits are expanded out • surprisingly compact (~ same size as source)
  • 32. The Tasty Vision Tasty .scala (2.x) .scala (3.x) .class (Java 8) .js .class (Java 11) .out macros analyzers optimizers IDE LSP
  • 33. Tasty Use Cases • Separate compilation • Language servers for IDEs (via LSP) • Macros • Cross-building à escape the curse of binary compatibility
  • 34. Meta Programming, So Far • Def macros (experimental), macro paradise (plugin). - Both are thin veneers around nsc. • Scala Meta: External tools that analyze and transform programs.
  • 35. Principled Meta Programming 2 + 2 fundamental operators: ‘( … ) (quote) ~(...) (splice) run inline Quote, splice + inline : macros Quote, splice + run : staging
  • 36. Principled Meta Programming T Expr[T] Restriction: Can’t look inside an Expr. splice ~(…) quote ‘(…)
  • 37. Principled Meta Programming T Expr[T] tasty.Tree Solution: Bijection between Expr[T] (high-level) and tasty.Tree (low-level) reflect reifysplice ~(…) quote ‘(…)
  • 38. The Tasty Vision Tasty .scala (2.x) .scala (3.x) .class (Java 8) .js .class (Java 11) .out macros analyzers optimizers IDE LSP
  • 39. New Macros are “Blackbox” They get expanded after type checking. à Program must typecheck before macros are expanded à Macros always work on typed trees à Hygienic by definition à Drastically reduces # things that can go wrong
  • 40. Language-Level Solutions for Lazy implicits ✔ Type lambdas ✔ Context injection ✔ Typeclass derivation (still to do) Typelevel functions (to be explored)
  • 41. Migration • Despite many differences, Scala 2 and 3 are still fundamentally the same language • Source compatibility for common subset. • Rewrite tools can handle much of the rest (macros are the big exception here). • Situation better than for Python 2 vs 3 because of static typing & binary compatibility.
  • 42. Binary Compatibility today: Dotty can link with Scala-2.12 class files. Scala 2 module Dotty module
  • 43. Binary Compatibility today: Dotty can link with Scala-2.12 class files. planned: Two way compatibility using Tasty as common intermediate format. Scala 2 module Scala 3 module Scala 2 module Scala 3 module
  • 44. Roadmap 2018 Flesh out design Dotty 0.x Get feedback Refinements 2019, first half -------------- Feature freeze --------------- Scala 3 Stabilization dev previews 2020, first half Scala 3.0
  • 45. Stability So far: • Most Scala 2 regression tests are in the Scala 3 test suite. • Community build for core libraries and tools. • All tools are built using Scala 2 first, and then again with dotc.
  • 46. Stability Planned: • Once there are developer previews, ensure that core projects are published for Scala 3. • Use dotc itself as the bootstrap root. à“eat our own dogfood” should use Scala 3 features in our own tools.
  • 47. Try It Out Today! dotty.epfl.ch New versions are released every 6 weeks.
  • 48. Questions, Suggestions, Concerns? Talk to us anytime. Also, there’s a panel where we will respond to questions at the end of the conference. Plus, a contributors workshop on Friday. Talk to Heather if you want to go.