mitchus
mitchus

Reputation: 4877

How strongly is scala tied to JVM?

I have been wondering if Scala has any particular properties that make it inherently dependent on the JVM, or if it could be viable on top of something else. I can see how both the JVM's ubiquity and continued improvements, and the interoperability between Java and Scala, are strong arguments for this strategic choice. However, I understand that for this reason, compromises were made in the language design.

If the days of decline were to come for the JVM, would Scala go down with the ship, or could there be life after the JVM?

Upvotes: 18

Views: 1694

Answers (1)

om-nom-nom
om-nom-nom

Reputation: 62835

There were projects to have Scala running on .NET runtime (discontinued, the person who worked on it is improving the compiler backend for future versions of Scala) and LLVM (stuck). Moreover, there are several backends for Scala -> Javascript (e.g. scala js), so I would say it is possible to untie Scala from the JVM in some sense.

At the same time many Scala APIs depend on Java APIs, many optimizations and inner workings are implemented with respect to the JVM. There is a number of discussions on mailing lists on Scala without JVM, Scala with it's own virtual machine and so on, e.g this one, but as far as I know, the official statement is to support non-mainstream JVMs as well (Avian for example), rather than having an own runtime. This way Scala can be run on iOS and Android (and PCs of course).

As Simon Ochsenreither noted, Avian is not just yet-another JVM, but comes with some distinct advantages compared to HotSpot:

  • Ability to create native, self-contained, embeddable binaries
  • Runs on iPhone, Android and other ARM targets
  • AOT and JIT compilation are both fully supported
  • Support for tail calls and continuations
  • An intelligible code base
  • Responsive maintainers
  • Open for improvements (value classes, specialization, etc.)

Upvotes: 20

Related Questions