> Scala 3 has an option to exempt null from ordinary types, marking nullable types as T | None, so this is not related to the JVM
I don’t know scala 3 well, but if it can make nonnullable types (that’s what “exempt null from ordinary types” means, isn’t it?), that’s not something the JVM knows about (although that may be changing with the addition of value types to the JVM)
Even if that’s incorrect, there are plenty of other examples of types that map badly to the JVM, such as Either[String,String] and AnyVal (a scala class with subclasses such as Int)
Another example are value classes, which are values until they aren’t. https://docs.scala-lang.org/overviews/core/value-classes.htm...:
“Universal traits allow basic inheritance of methods for value classes, but they incur the overhead of allocation”
And yes, scala3 has opaque types, but in the JVM, those must revert to their underlying type (if they don’t, the performance gains are lost), and scala3 also still has value classes.
> this can be completely decidable at compile time.
It can’t the moment you load a jar and call a method in it, and I think about every scala program does that.
> The reflection claim is also questionable
The JVM has strict single inheritance. Scala supports a form of multiple inheritance through traits. There’s no trivial way to map that to the JVM.
> In fact, erasure of generics help with guest languages, as it doesn’t bake into the variance.
I don’t understand that. It surely doesn’t always help. Scala reflection doesn’t want erasure, so they’ve had to work around that.