3 ms·
My assertion that Java is displacing C++ is admittedly very anecdotal, this is a difficult claim to discuss in rigorous terms. My claim is based on personal exp
by benreesman 18y ago
My assertion that Java is displacing C++ is admittedly very anecdotal, this is a difficult claim to discuss in rigorous terms. My claim is based on personal experience, the experience of colleagues, and "some people I've talked to on the interwebs", so by all means take with a grain of salt and do some research yourself if you're skeptical.
For any long-running process the JIT is going to turn your Java (Clojure, Scala, ...) into extremely well-optimized machine code. In fact, the amount of knowledge that the JIT has about the actual run time behavior of the software allows it to do better optimizations than you ever could by hand in certain situations (an ever-growing number of situations).
GC is another point, the HotSpot GC is arguably faster at allocating small, short-lived objects than malloc is. It is reeeaaaaallllyyy good these days, probably the best GC that you'll find in production just about anywhere these days. The thing is a monster. And the new one, the G1 collector, was sent from the future by SkyNet to kill John Conner.
Add to this the fact that you can easily exploit common multiprocessing patterns (thread pool, consumer/producer) with almost no code, and that advanced multiprocessing code can be written in a platform independent way, and it's a pretty small subset of applications that still make sense to write in C++.
Add to all of that the fact that even Java (let alone all the other amazing JVM languages) are orders of magnitude more productive than C++ for your programming staff, and the set of situations in which it makes sense to use C++ rather than the JVM is looking pretty tiny.
Oh and then there's portability. C++ isn't even portable across compilers (versions of the same compiler!), and for all the early trouble with Java portability, it really is write-once-run-anywhere now. Really.
- 10ren 18y agoGood to see a fellow Java fan here. But C/C++ is still faster than Java (and assembly is faster still), if you really need performance. A big minus for Java is hard realtime performance (illustrative eg: it's hard to get regular framerates); which of course doesn't matter on the server you're discussing. A counter-argument is that if you need multicore, it's because you need performance; and if you need performance, you probably need C/C++. Java has many benefits as you mention, especially ease of development, and I think these are what drive its adoption rather than any multicore benefit. So, I accept your (a); and (b) certainly has some truth, but I doubt the causality of (c). The stats (terribly unreliable) show that C and C++ combined are ahead of Java, and the proportions are fairly static (C and C++ are steady, but Java is itself being javaed by even easier languages like Python (which incidentally supports my reasoning above): http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html http://www.tiobe.com/index.php/content/paperinfo/tpci/index.... (about as reliable as a slashdot poll, but it's probably basically right).
- benreesman 18y agoAn interesting case of the deep-nested delay affecting a cool-headed and respectful discussion. Law of unintended consequences I guess. I would respectfully contend that outside of micro-benchmarks (which kill Java because of long startup time and no chance to JIT) that Java is as fast as C++, and in the presence of lots of cores probably faster. This is again based in large part on my direct anecdotal experience, I would be very interested to hear about everyone else's experience in the matter. But the real point is that with Moore's law now working on cores instead of mhz, single-threaded performance just doesn't matter that much going forward. Exponential increase and all that. For a look at where this shit is going take a look a look at Azul. http://www.azulsystems.com/ http://www.azulsystems.com/
- 10ren 18y agoI think that was its intended consequence (though it didn't affect my replies.) I'm glad I put you on the spot, because your reasoning was worth hearing. You're making an interesting case. I haven't heard any claim that Java actually is faster than C++ in practice, just that it theoretically could be, because of JIT optimizations (then again, I don't think C/C++ is used that much in the server, anyway.) I also haven't heard of Java getting a comparative advantage due to multicore, just that FP would. But that's not to say it isn't true. You could be right. Interesting. (The link seems to be commodity computing, like Sun blade servers).
- benreesman 18y agoLet's carry on this conversation via email, my address is in my profile. I can share with you some of the sources that have led me to form this opinion. +1 thoughtful and respectful debate.
- icey 18y agoIt's kind of a shame that the code that was meant to stop flamewars stymies interesting conversations like this one.