Note: Look here for 3.0 benchmark numbers
The release of Scala3 is imminent.
In April I ported/migrated nmesos from Scala2 to Scala3 and I just did a quick benchmark to see what Scala3 is doing to my Advent-of-Code implementation from 2017.
Initially I was wondering (and maybe a little bit afraid) how difficult migrating to Scala3 will be (and what problems I will be running into).
The good news is that migrating to Scala3 is not difficult at all. Mainly because of the Scala2/Scala3 interoperability, which means that as long as you are on Scala 2.13
you are more than half-way there.
Which leads to the main challenge (at least from my point of view) and that is the upgrade to 2.13
. Both of my migration projects used old(er) versions of Scala and I first had to upgrade both projects and all of the dependencies to Scala 2.13
, which was 80% of the work/effort.
And yes, on top of that you need to keep an eye on the marco-based libraries that need to be migrated to 3.0
and are not migrated yet, but this list will get smaller fast/soon (and was not a problem for me).
Which leads to the question: Why to migrate to Scala3 (right now)?
The short answer is probably, that if you do not have a very specific reason (e.g. a bug/bad behavior in Scala2 that is bothering you) there is no need to migrate right now.
Instead I would spent time to make sure that my code is current (run/uses 2.13
), which is a good practice anyway and then migrate to Scala3 when a reason to do so materializes itself.
Now … one question that always comes up is, if run-time performance is one of these reasons. The short answer is probably no, because the performance of Scala3 is mainly determined by the performance of the 2.13
standard libarary, means I do not expect 3.0
to be much faster then 2.13
. And I also expect that is is not going to be any slower than 2.13
(mainly because benchmarking 3.0
against 2.13
is an on-going effort).
At the same time I have to say that I did my own benchmarking and compared the performance of 2.13
with the performance of 3.0.0-RC3
finding the solutions for the 2017 Advent of Code and for Day 18, 22 and 25 I saw performance degradations that I want to investigate more (I will probably wait until 3.0 is released and run the benchmark again).
Last but not least I also want to call out that from my experience the Scala3 compiler (dotty) is not faster or slower than the Scala2 compiler (compiling my Advent of Code project takes 11 secs in both cases).
All of this lacks scientific rigour, but gives nevertheless a good first impression how migrating to Scala3 will look like.
For me the key take-a-way is that there are probably good reason to upgrade to 2.13
, but I do not see a reason to rush the upgrade/migration to 3.0
. At the same time it seems, that if you end up with a reason to migrate to 3.0
, it is a very do-able task.