0

As I am moving to help my organization adopt scala 3, i am trying to map out the potential chanllenge to look after.

Generally, i was readying about binary compatibility change with scala 3 and something wasn't quite clear to me. It is best summarised by the following question:

What happens if a library is developped with scala 3.4.1 and someone try to use it in a project that run 3.2.1 ? From my understanding given that forward compatibility is not a garantee there will be a runtime exception. Totally fine and understandable. So in fact the real question is, given that we remove the second number when pubishing a library, meaning library are published as 3 as opposed to** 3.4**, how do a user know that he can't use that library in his project which is at 3.2.

I am wondering what's the best practices that the community is putting in place to handle this scenario gracefully. Is the expectation that, basically, we assume the user will have good tests suit, which will fail with a runtime failure, and then figure out that it is time to upgrade their project version which "supposedly" they can now do safely and systematically because of the strong garanteed backward compatibility. I said supposedly because of course, in the context of an organization and given the jvm eco system there are a host of concern to take into acount before upgrading anything.

What measure are we expecting the different parties involved to take (library maintainer n user), to make that particular scenario something not that painful.

1 Answer 1

4

From Long term compatibility plan:

Scala 3 guarantees backward compatibility between all releases and forward compatibility between patch releases in the same minor line. That means that Scala 3.b.y can consume the output of Scala 3.a.x only if b is greater or equal to a. For example, the output of the Scala 3.0.2 compiler can be used by Scala 3.0.1 or 3.1.0. On the other hand, code compiled with Scala 3.1.0 cannot be a dependency of any project compiled with 3.0.2.

The best practices

Once the LTS & Next model is in place, we suggest the following practices for different groups of users:

Owners of commercial projects

We suggest you stick to the LTS version. It will give you the best tooling support and a stable compiler. If you are migrating a bigger project from Scala 2, you should migrate it straight to the newest LTS.

You may also choose to be up to date with the latest minor version. That will allow you to use new features as soon as they are added to the language. However, you will need to be ready for frequent compiler updates. Otherwise, your project may end up with an unsupported language version.

Library maintainers

Unless your library is built around some new language feature available only on Next, you should stick to the latest LTS version to have the broadest possible user base. If your library contains multiple modules, some of them may require Scala Next. It is perfectly fine as long as you keep in mind that modules compiled with Scala LTS cannot depend on them (the other way around is fine). Also, users using your library from Scala LTS won’t be able to access modules built with Next.

Remember that when you bump the minor version of the compiler (e.g., moving from the previous Scala LTS line to the next), you also need to bump the minor version of your library.

Authors of hobby or standalone research projects

Feel free to use Scala Next. Then you will be able to use all libraries, both those for Scala LTS and Scala Next. You also will be able to test the newest and experimental features of the language.

The current LTS being 3.3.x.

Not the answer you're looking for? Browse other questions tagged or ask your own question.