File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Scala and the fly likes Issues with Scala built on JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » Scala
Bookmark "Issues with Scala built on JVM" Watch "Issues with Scala built on JVM" New topic
Author

Issues with Scala built on JVM

munthajeeb akbar
Greenhorn

Joined: Mar 06, 2008
Posts: 4
Firstly the introduction in the book FP in scala focusing on FP and using scala as an example is excellent and very helpful since the power of scala is in understanding FP well. - Thanks a lot for writing this book !!!
my questions on scala:-
1) does scala have any performance improvement compared to Java ?
2) if the underling JVM changes how will scala survive ?
3) is there any limitations on scala since it is build on top of JVM ?
Runar Bjarnason
author
Greenhorn

Joined: Feb 18, 2014
Posts: 12
does scala have any performance improvement compared to Java?


No. Scala code is exactly as fast or slow as the equivalent Java code.

if the underling JVM changes how will scala survive?


If the JVM changes, I suspect Scala will change too.

is there any limitations on scala since it is build on top of JVM ?


There are some limitations that come with the JVM, yes. For instance, there is no JVM byte code for tail calls. Tail call elimination is particularly important in FP, so we have to resort to techniques like trampolining (covered in chapter 13 of the book).
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

I have a rather strange question. In Scala each function ends up as a class file after compilation. If I have say 100 functions in a Scala class, I end up having roughly 100+ classes and loading all these functions as classes in the memory during run time would cause performance issues? Can you please throw some light on that?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Runar Bjarnason
author
Greenhorn

Joined: Feb 18, 2014
Posts: 12
Joe Harry, that is another historical limitation of the JVM. Until Java 7 there was no way to get an unboxed method handle in the compiler, so in order to get first-class functions Scala and others resorted to anonymous classes with a single method (Function1 and friends). This definitely has a memory overhead.

Note that Scala methods are still just ordinary methods. This limitation is specific to first-class functions, or closures.

As of Java 7, the JVM provides method handles first-class in the byte code. So hopefully Scala will take advantage of these at some point.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688

Hi,

May be this will help you..

First Class Function Scala


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issues with Scala built on JVM