1

There is a Scala library I would like to use (PiStache) that was written for Scala v2.9 and hasn't been updated in 7 years.

Q: Can anyone point to a conversion or migration guide for Scala v2.9 to the most current v2.12.x?

I have searched the web for any conversion or migration guides, and haven't found any. The only option I see is going through the successive release notes hoping they list incompatibilities.

I have found various discussion threads that describe why there there are incompatibilities between minor versions, but no succinct list of changes that need to be made. Of course, I could take the trial and error approach and simply compile the library under 2.12.x and then respond to error messages, but I'm hoping to avoid that (potentially) time consuming process.

MrMeritology
  • 171
  • 9
  • 2
    In general, Scala has a deprecation period of one release cycle. So, any code that compiles with 0 warnings and errors using `scalac -deprecation` and without using any experimental features in Scala 2.9, should also work in 2.10. However, there are no tools that span more than one release, you will have to take it one step at-a-time. Note that when you *do* get deprecation warnings, they usually also explain what can be used as a replacement and how. – Jörg W Mittag Apr 23 '18 at 20:24
  • @JörgWMittag thanks! That is a very practical and systematic approach, though perhaps time consuming. – MrMeritology Apr 23 '18 at 20:33
  • 1
    @JörgWMittag As it happens, this particular library has almost no external dependencies and very small code base, so I'm anticipating an easy migration. (famous last words :-) – MrMeritology Apr 23 '18 at 20:48

1 Answers1

3

The best migration guide I found is here (2 parts), focusing on 2.9 -> 2.10 migration:

tl;dr: Most of the migration effort is tied to libraries, and if library authors have newer (compatible) versions then you are good. But there are a variety of small changes to Scala library that you might stumble on:

The Scala class library itself has a number of changes you ought to be aware of before migrating to 2.10. The really big change is that Scala actors are deprecated in favor of Akka. You can still use them by importing the scala-actors artifact from the Scala 2.10 distribution, but it is recommended to migrate fully to the new actor system as this is also likely to be obsoleted by 2.10.1. The gentle folk at Typesafe have provided a very comprehensive migration guide to assist your efforts.

The less prevasive API changes we ran into include:

  • List.elements is deprecated in favor of List.iterator;
  • TraversableOnce.toIndexedSeq no longer takes a type argument. This was actually quite pervasive in our codebase, causing plenty of compilation errors, and is easily worked around by removing the type parameter (which is extraneous to begin with);
  • Scala actors' Actor.receive method is now public (previously protected). This had to be rectified in pretty much all of our existing actors by removing the protected modifer;
  • Occasional subtle API changes requiring minor code fixes, e.g. Enumeration and Mapping.

Regarding 2.10 -> 2.11 (from Release Notes, emphasis added):

Code that compiled on 2.10.x without deprecation warnings should compile on 2.11.x (we do not guarantee this for experimental APIs, such as reflection)

Regarding 2.11 -> 2.12 (from Release Notes, emphasis added):

Although Scala 2.11 and 2.12 are mostly source compatible to facilitate cross-building, they are not binary compatible. This allows us to keep improving the Scala compiler and standard library.

CAUTION: For anyone using Apache Spark, note that the latest version 2.3.0 is not compatible with the latest version of Scala 2.12.x, so you are forced to use Scala 2.11.x until this changes (fairly soon, from discussions I've seen).

Community
  • 1
  • 1
MrMeritology
  • 171
  • 9