For parallel processing of graphs such as shortest path computation, would Scala outperform C++? If not, how much slower would it be (I’m assuming Scala concurrency is “easier” to write than C++ since C++ has no standard support for such things)
I’m considering learning Scala at the moment, both to learn a new language and because it seems to have good concurrency support. Once I’m done, I’m considering writing a distributed graph library to practice Scala, and for my own use, but if C++ is going to be faster and the benefits of easier to write code is not worth the tradeoff when performance is a concern, I’ll have to rethink that quest.
I’d suggest Scala over C++ for the following reasons:
Of course, it is possible to write extremely performant code in C++. There are some situations where hand-tuned C/C++ code can outperform the JIT (e.g. by avoiding the need for array bounds checks or null pointer checks when you can prove that they aren’t needed). Or you can write your own memory allocator that is specialised for graph processing and which theoretically might outperform the general purpose garbage collector in the JVM (though you better be a true genius if you want to try this….)
Overall though, it will be much more complex to write everything in C++ and the marginal performance improvement that you might theoretically be able to achieve is almost certainly not worth the effort.