dotty scala3 adoption report: easy so far

dotty scala3 adoption report: easy so far

I decided to use dotty (aka Scala 3) for a small machine learning (NLU) project to get a feel for new features and ecosystem components. I try to keep my code simple to write and understand. I tend to avoid the use of advanced type features, and I am Ok if I avoid “purist” FP thinking. I don’t mind a little boilerplate.

Here’s some feedback. More to come when the project is complete:

  • Adoption: Easy. I read some dotty slides for an hour. Then I read the dotty doc site for another hour. So far, the dotty features I have chosen have been easy to adopt, e.g., implicits with the new syntax via given. Dotty is an experimental compiler, and I found a bug! The dotty team fixed it within a few days–thanks!
  • New features: I am using a few, new features including:
    • implicit functions (they immediately added value)
    • objectless toplevel code
    • extension methods
    • ADTs via enums
    • union/intersection types
    • exports
    • The features were easy to learn, adopt, and I quickly became used to them. I had a few assists from the gitter dotty channel about a few complex features but I dropped their use until they are better documented and fully implemented.
  • sbt support: You can use scala2 (less macros) by using a sbt syntax extension on your scala2 dependencies in build.sbt. This approach has worked for cats, circe, zio and a few other libraries I needed.
  • Roadmap: The team seems to have listened to the community about migration support, backward compatibility, and editor support out of the box. These topics are discussed in multiple venues. The Roadmap schedule appears to provide a generous on-ramp period, and there is consistent communication about features, development process, and the schedule.
  • graal (not dotty related): I have sbt running on graal, and I use graal as much as possible. I do not know if it is graal or sbt updates or both, but compilation (delta and full) is fast. graal also gives me a path, along with scala-native, towards mobile devices running ios and android. Oracle is heavily investing in graal. Allowing graal to do the heavy-lifting for mobile is a smart move and probably was part of an unspoken plan to have scala be relevant on mobile devices. As a side note, graal renewed my faith in JVM-based languages.

I like dotty’s new syntax and features. It was straightforward to pick up. Perhaps for code that uses simpler scala 2.x features, the conversion may be relatively easy although not cost-free. Hopefully, runtime performance will be excellent once GA.

My experiences may not overlap with those that have large complex code bases to build and maintain. My initial reaction is that the transition to scala 3 may have some bumps along the way, but it does not appear to be earth-shattering or overly difficult. The scala teams seem to be taking reasonable steps to make it easy.

At this point, I think that scala 3 success is related to the execution of the plan vs. a lack of strategy.

After adopting dotty, I was back to the same challenge I always have: how to represent my data and functions in a way that compose and are fast to run. I have some new tools in the toolbox to help me.

Note: The project depends on zio, xtract, circe and cats.

Comments

Popular posts from this blog

quick note on scala.js, react hooks, monix, auth

zio environment and modules pattern: zio, scala.js, react, query management

user experience, scala.js, cats-effect, IO