-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adopting Scala 3: Why Does It Still Support Deprecated Syntax? #22609
-
Hey folks,
I'm working at a company with dozens of Scala developers, and we recently started adopting Scala 3. So far, so good—except for the mixing of Scala 2 and Scala 3 syntax in Scala 3 codebases. We assembled a small team who "jumped into the water" and wrote a brand new service in Scala 3. The service works well, but the code ended up being a mess of implicits and givens, classic and braceless syntax, as well as both the old and new conditional syntax.
While I understand that this mix can be useful during the transitional phase from Scala 2 to Scala 3, it’s a disaster for a new project. Scala isn’t the simplest language to learn, and having both Scala 2 and Scala 3 syntax in the same codebase only adds to its complexity.
Fortunately, we discovered two compiler flags—-old-syntax and -no-indent—that help maintain consistency and reduce the syntax variety in our code. However, some features, such as implicits (which have been replaced in Scala 3 by givens and extension methods), cannot be disabled or phased out via a compiler flag.
For someone starting a new project, it makes sense to write pure Scala 3 code. I believe the compiler should offer a "strict" mode that disables backward-compatible Scala 2 syntax entirely.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments
-
Not all of that is just "backward-compatible". For example, we extensively discussed braces during the design phase of Scala 3, and agreed that braces would remain available indefinitely, because many of us really don't like the braceless syntax. I don't have any intention of going to pure-braceless, pretty much ever -- I find it harder to read in some cases, and IMO the new syntax is cryptic around the edges, and harder to teach.
I agree that a strict mode isn't a bad idea when it comes to clearly-"legacy" bits like implicit
. But the lines of what comprises "legacy" are still somewhat fuzzy.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Maybe it could be because Ive already spent 5 years with the new syntax, but for me syntax variations leave no impression on me, even when mixed in the same class - i only see the underlying concepts
Beta Was this translation helpful? Give feedback.
All reactions
-
a mess of implicits and givens
About implicit
specifically, on Reddit recently Martin wrote:
The current plan is to drop
implicit
syntax sometimes soon after the next LTS (which is planned for late 2025). Libraries that need to cross build can still do this by setting their source version to that LTS.
source: https://www.reddit.com/r/scala/comments/1jisl6i/comment/mjiweg2/
Beta Was this translation helpful? Give feedback.