Making the Transition�to Scala 3
Seth Tisue / Lightbend, Inc.
Twitter: @SethTisue�GitHub: SethTisue
Scala in a nutshell
Scala = object-oriented programming + functional programming
targets: JVM (Java Virtual Machine),� but also JavaScript (Scala.js) and LLVM (Scala Native)
built around a Java-like core;� Java programmers can begin by writing Java-like code
Scala prioritizes type safety
normal Scala code uses immutable values by default
Scala 2 timeline
Scala 3 timeline
2012 — first commit
�2020 — Dotty (experimental compiler)� becomes Scala 3
2021 — 3.0 (May), 3.1 (just released!)
2003 — first commit
2007 — Scala 2.6
2008 — Scala 2.7
2010 — Scala 2.8
2012 — Scala 2.9, 2.10
2014 — Scala 2.11
2016 — Scala 2.12
2019 — Scala 2.13
2021 — Scala 2.13.6
Scala @ Twitter
Spark
Akka
Kafka
Reactive Manifesto
The Scala organization
nonprofit / academic
companies
Prof. Martin Odersky
Who am I?
Full-time Scala coder (2008–)
Scala community organizer (2009–2016)
Scalawags podcast (2014–2016)
Scala Improvement Process committee (2014–)
Compiler hacking, open source, community relations
@ Lightbend (2015–)
Why upgrade?
because Scala 3 is…
Scala 3 is still Scala
The Scala 3 uses the Scala 2.13 standard library AS IS.
Scala 3 is still Scala
Nearly all Scala 2 code is also�valid Scala 3 code.
Scala 3 is still Scala
Library & tooling ecosystem is already large.
Scala 3: benefits
Quality
stronger theoretical foundations� Scala 3 = Dotty = DOT = Dependent Object Types
stronger practical foundations� new compiler = less tech debt
“Fixed in Scala 3”
(the true numbers are�surely much higher)
Benefits: UX
Design goal:
Benefits: UX
Design goal:
Features are “new”, yet already familiar
Benefits: Implicits
“Implicits” redesigned
Benefits: Implicits
“Implicits” redesigned
Benefits: Context functions
Brachthäuser,�Boruch-Gruszecki,�& Odersky��ICFP 2021��https://www.youtube.com/watch?v=UmO-f0qTRSU
Benefits: Syntax
cleaner, indentation-based syntax
Scala 2
Scala 3
Benefits: Enumerations
Enumerations
Benefits: Enumerations
Enumerations — simple
Scala 2
Scala 3
Benefits: Enumerations
Enumerations — advanced
Scala 2
Scala 3
Benefits: Opaque types
“Opaque types” provide zero-overhead abstraction
Benefits: Metaprogramming
new metaprogramming features
Scala 2: experimental macro system� workable, but cumbersome and fragile to create
Scala 3:
Benefits: Metaprogramming
Benefits: Metaprogramming
Macros are needed less often.
Benefits
also, talks yesterday by:�• Dean Wampler�• Bill Venners
Advice
Be bold!
Type safety will protect you.
Strong compatibility story will protect you.
Yet be cautious, too...
Advice
Advice
Migrate advanced, Scala-friendly teams first
Scala 2 remains the safest choice�• for less experienced teams�• for less enthusiastic teams
Advice on dependencies
Caveat #1: Macros
Caveat #2: Diamond dependencies
Advice on dependencies
App 2
Library C for 3
Library D for 3
Library E for 3
Library E for 2.13
for3Use2_13
App 1
Library A for 3
for3Use2_13
Library B for 2.13
Library D�shouldn’t�do this!
Advice
IDE support is already pretty good�(IntelliJ, Metals + VS Code)
Advice
3.0 shipped when:
design decisions were made�quality & tooling good enough to create Scala 3 libraries with
3.0 did not wait for:� tooling to be fully on par with Scala 2
Advice
Advice on cross-building
Advice
Advice
Advice
Advice
Not at all?�Gradually?� by file, by class, by method�All at once?
most common?
Learning materials: Videos
“Let’s Talk About Scala 3”�12 videos, 10–25 mins each
Learning materials: Free online courses
new course:
the classics, updated:
Learning materials: The Scala 3 Book
free on Scala website
author: Alvin Alexander
Learning materials: Books
Learning materials: Books
MEAP = in progress
“Functional Programming in Scala”
by Runar Bjarnason & Paul Chiusano��new co-author:�Michael Pilquist (of Typelevel, FS2 fame)
Questions?
FAQ