Search code examples
scalajvmscala-native

Can I run my scala program without JVM using scala-native?


I heard about scala-native recently and it sounds very interesting !
I'm curious about what does native means here ?
what does "ahead-of-time compiler" means ?
I think descriptions in the web site and github repository are not clear.


Solution

  • Can I run my scala program without JVM using scala-native?

    Yes, the goal of Scala Native is to support compilation of Scala programs without any kind of VM. We've not had a stable release yet, follow us on twitter to be the first to know when this happens.

    I'm curious about what does native means here ?

    Scala has historically been a language that runs on Java Virtual Machine. Unlike native applications, Java applications are built on top of an additional indirection layer that maps virtual machine instructions to underlying hardware instructions. The code is still eventually compiled to native code, the only difference is that it happens later on, during the run of the application. This is also known as just-in-time compilation strategy.

    what does "ahead-of-time compiler" means ?

    "Ahead-of-time" means that mapping from high-level Scala code to low-level native code is done in advance, before the application is actually run. This saves us some indirection overhead, and reduces overall resource consumption.