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 ?
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).
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!
Joined: Feb 18, 2014
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.