Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving the JVM for Scala [closed]

Tags:

jvm

scala

What changes to the JVM would most benefit the Scala compiler and runtime?

The dynamic languages will benefit greatly in performance from the introduction of the InvokeDynamic byte code scheduled to arrive in JVM 7 and Scala will probably benefit from tail recursion (not sure if it will appear in JVM 8 or later).

What other changes could Scala, with its present feature set, benefit from in the JVM? Are these changes on the horizon?

Specifically, are there changes to the JVM that would improve performance with closures and functions-as-objects?

like image 478
Ralph Avatar asked Apr 18 '11 17:04

Ralph


People also ask

Is Scala losing popularity?

Scala's popularity shot up, becoming the 20th ranked language on the TIOBE index in 2018. Today it is lower, although it is No. 14 on Redmonk. According to Oliver White, chief editor at Lightbend, the company behind Scala, the programming language supports companies with valuations in the hundreds of billions.

Is it worth learning Scala in 2022?

Scala is worth learning in 2022. The demand for Scala developers is high, and the pay is good. LinkedIn currently lists over 24,000 Scala jobs. According to ZipRecruiter, the average Scala developer salary in the United States is $139,292 a year.

Does Scala depend on JVM to run?

The Scala compiler ( scalac ) produces JVM bytecode ( . class files), as much as the Java compiler ( javac ). To execute these files you need a JVM. So, technically, a JRE is enough.

Can Scala run without JVM?

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.


1 Answers

Basically, everything that John Rose has been campaigning for :)

  • Fixnums - To eliminate the cost of boxing/unboxing primitives.

  • Method Handles - Would speed up higher-order functions and allow the JVM to optimise them more effectively. SAM types can sometimes require an awkward flip/flopping between monomorphic and megamorphic call sites that prevents inlining.

  • Continuations - To support asynchronous/concurrent design, as per node.js

  • Interface Injection - Simplify mixin composition and the implementation of roles, as well as eliminating the need for generating some intermediate classes and making structural types possible without reflection in many cases.

  • Tail-call optimisation - Should be a no-brainer :)

Reification is often quoted as something that would benefit Scala's pattern matching, but this would come at a high cost in terms of interop, given the different variance schemes that the two languages use. At this point, I believe that reification may actually cause more harm than it would do good.

I also think it unreasonable to expect anything that would break backwards compatibility in Java. That just ain't gonna happen.

like image 62
Kevin Wright Avatar answered Oct 29 '22 15:10

Kevin Wright