What is Scala 3 (Dotty) and its major changes?
Answer
Scala 3 (codenamed Dotty) is a major revision of Scala with cleaner syntax and improved type system. Key changes: given/using: replace implicits with explicit, readable syntax. given intShow: Show[Int] with { def show(n: Int) = n.toString }. extension methods: extension (n: Int) def doubled = n * 2; 5.doubled. Enum: first-class ADTs: enum Shape { case Circle(r: Double); case Rectangle(w: Double, h: Double) }. Union types: def f(x: Int | String). Intersection types: A & B. Opaque type aliases: opaque type Email = String. Context functions: type Builder = (Config) ?=> Unit. Match types: type-level pattern matching. Indentation-based syntax (Python-like, optional). Scala 3 addresses many criticisms of Scala 2's implicit system and provides a cleaner foundation for both OOP and functional programming.
More Scala Questions
View all →- Intermediate What is the type class pattern in Scala?
- Intermediate What is Akka and what is the actor model?
- Intermediate What is Apache Spark and how does Scala relate to it?
- Intermediate What is Scala's approach to concurrency with Futures and Promises?
- Intermediate What are Scala's monads and how do they work?