Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should a Scala developer know about Java and/or the JVM?

Tags:

java

jvm

scala

So up until about 6 months ago, most of my work (big graph processing) consisted of Python and C++. Up to that point, and even now, I had not written any Java whatsoever.. I had seen the language and was familiar with the syntax (having come from a C/C++ background), and liked the idea of the JVM, but never actually written any substantial amount of Java.

When I picked up Scala, I loved it, OOP and functional programming features all in one, and it being on the JVM was great. I've been constantly striving to improve my Scala and have been playing with Akka, and still loving it. However, at times, perhaps it is just me overthinkng it, but I feel I should learn some more about Java and/or the JVM.

I've heard from many that Scala should be considered a separate language from Java, much like C++ to C. Perhaps you may feel the same way, and perhaps learning Java is more or less disjoint from learning Scala, but I'm feeling learning more about the JVM (e.g. JIT compilation, type erasure) would be helpful?

Thoughts?

like image 610
adelbertc Avatar asked Jul 06 '12 08:07

adelbertc


People also ask

Do you need to know Java for Scala?

If you are considering diving into Scala, having a background in Java will obviously help and you'll have no trouble finding learning resources online. However, if you have no Java experience, you will need to learn the basics. Familiarity with functional programming languages will help as well.

Should a Java developer learn Scala?

A modern software developer working on the Java stack needs to know more than just Java, and it behooves every software developer to gain a certain level of competency in languages like JavaScript, Ruby and Scala, at the very least.

Does Scala work on JVM?

Scala source code can be compiled to Java bytecode and run on a Java virtual machine (JVM). Scala can also be compiled to JavaScript to run in a browser, or directly to a native executable.


1 Answers

  1. The JVM executes Bytecode and it is definately helpful to know how this works, just as it is sometimes helpful to know how C/C++ method invocations work or how classes are initialized; because sometimes it matters and cannot be abstracted away.

  2. Java is the prime language for the JVM, and it is helpful to be able to read Java to some extent if you need to use Java classes directly. And this may happen quite often; only a few examples:

    • you need to use some third party Java library (and there are tons)
    • working with Properties
    • you need to do something special in Swing which is not supported by the Scala-Swing wrapper
    • also sources explaining stuff for 1) will most probably use Java examples

But my advice is not to study it in advance - you'll pick it up when you need it.

like image 92
ziggystar Avatar answered Oct 20 '22 21:10

ziggystar