Wednesday, 2 March 2016

Scala 2.11 GenASM Vs Scala 2.12 GenBCode


In this post, we are going discuss about Scala's JVM BackEnd and ByteCode Optimizer of Both Scala 2.11 and Scala 2.12 versions.

TypeSafe  (Or Lightbend) Team is going to change Scala's Backend and ByteCode optimizer in Scala V.2.12.

Scala 2.11 Backend: GenASM

Scala v.2.11 uses GenASM as it's Backend and ByteCode optimizer.

If we want to use Scala current version 2.11 but with new Backend and ByteCode Optimizer, then use 'backend' option as shown below:

$scalac -Ybackend:GenBCode Sample.scala

Scala 2.12 Backend: GenBCode

Scala v.2.12 uses GenBCode as it's Backend and ByteCode optimizer.

Advantages of GenBCode:

  • Very easy to configure
  • More Reliable
  • Better optimization approaches
  • Better diagnostics
  • Better code analysis
  • Fewer components to maintain

And another major advantage of Scala V.2.12's GenBCode is that it generates same bytecode like Java's bytecode.

It supports Java SE 8 Features like Lambdas, SAM(Single Abstract Method) or Functional Interfaces etc.

Please drop me a comment if you like my post or have any questions or suggestions.

Thank you.