Now that I look at it, they essentially do, it's just that they implement it from a more Scala-centric point of view (e.g. implementing traits directly instead of being layered on top of a Java variant). It seems like it shouldn't be too hard to compile JVM bytecode to run on the same runtime.
Unfortunately it doesn't. Even though Scala and Java output the same kind of bytecode, these languages have different language specifications. We currently only support what's in the JLS.
This is the compiler from Scala to Java bytecode. It does type checking, some optimizations (like inlining, removing some instances of boxing, or converting tail-recursive functions to loops), and converts all Scala-specific features to some Java constructs (e.g. traits become interfaces, classes etc.; lazy values become methods and accompanying values; lambdas get lifted to the class they are defined in).
The JIT works on Java bytecode. Java also has a similar compiler (javac) from Java -> bytecode.
This all sounds right to me - scala needs first class support for what it is doing in the JVM itself - which it doesn’t have. Trying to ASM scala is a pain.
Scala is a JVM language. If it’s Scala.js, as referenced in a sibling comment, it’s still Scala being cross compiled. Therefore it’s still JVM at the source
reply