开发者

Questions on Java and Scala and parallelization

So, I have a couple of questions开发者_如何学C about scala.

1) Would writing a new project in scala be speedier (in terms of performance) or should I just stick to regular java? The project that I am going to inherit is already written in java, but it can be massively parallelized. Also, this project is for academic purposes, so I'm a little worried that it's not such a good idea. I know I'd have to run it by my supervisor first, but it's just a thought.

2) Just to be sure, I can compile my scala code on my computer and execute the "binaries" (compiled byte code) on a cluster that has the JVM installed?

3) If I were to compile the inherited java program, should it work? And should it be faster?

(The cluster uses SGE)


  1. This depends entirely on how much work you want to put into parallelizing your code (and how parallelizable the algorithms are). Scala makes it easier, but it does just run on the JVM, and Java can employ every threading trick known to the compiler. So if you want to put the effort into the Java, it will be at least as fast as Scala. (Then again, if you write your Scala like Java, there are very few instances where Java will be faster, so basically it's a tie.)

  2. Yes, as long as you supply the scala-library.jar file (and any others that are needed e.g. if you use Swing, which would be a strange thing to do on a massively parallelized system).

  3. Compiling java bytecode almost never is faster than running the bytecode on the JVM. The JVM is more clever than most static compilers.

  4. You didn't ask, but Scala doesn't have built-in support for the Sun Grid Engine. You could potentially set up something with remote actors, for example, but you'd have significant work to do there.


1) No, you won't get superior performance. Your speed as a programmer will be superior, once you get over the learning curve, but this doesn't seem to be your question.

It might be easier to parallelize by using Scala actors & futures or upcoming 2.9's parallel collections. Also, if the code is heavy on generics but has frequent use of boxed primitives, then Scala's specialization feature is much easier than doing the equivalent by hand in Java.

On the other hand, there's Akka actors and futures that are arguably superior and can be used fine from Java, and Java's own parallel stuff isn't bad.

2) Yes.

3) Err, what?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜