7 ms·
HotSpot is indeed one of the most optimized runtimes around. It is, however, optimized for large, complex applications. It's quite possible to beat in a careful
by pron 13y ago
HotSpot is indeed one of the most optimized runtimes around. It is, however, optimized for large, complex applications. It's quite possible to beat in a carefully designed microbenchmark. Beating it in a complex application is a whole other matter (in fact, it's pretty hard to beat even in C++).
- haberman 13y ago> in fact, it's pretty hard to beat even in C++ If there's one thing I've learned, it's that the wishful thinking will never stop.
- dman 13y agoWhat?
- deleted 13y ago[deleted]
- peterashford 13y agoThat's pretty snarky
- haberman 13y agoIt's really irritating, as someone who works in C and C++ with good reason, to hear people continually deny the very real performance benefits of working at a lower level. We (C/C++ guys) write the OS's, VMs, browsers, codecs, etc that power your software stacks, and then you (managed language fans) turn around and tell us we're wasting our time by using C and C++, while giving us stuff like Eclipse. So yes, when someone says it's hard to beat Java with C++, it inspires some snark. Write the next JVM in Java if you think it's that easy.
- hermanhermitage 13y agoThis is what happens when an important variable (the specific problem domain of performance comparison) is left as a free variable :-)
- waps 13y agoI think you'll find java's propensity to box everything to effectively mean that beating it is rather easy in pretty much any application that actually uses some memory. As will java's insistence to do everything in UTF-16.
- pjmlp 13y ago> Write the next JVM in Java if you think it's that easy. Jikes, http://jikes.sourceforge.net/ http://jikes.sourceforge.net/ Oh and post Java 8, Hotspot might be replaced with Graal a new JIT done in Java, https://wiki.openjdk.java.net/display/Graal/Publications+and+Presentations https://wiki.openjdk.java.net/display/Graal/Publications+and...
- haberman 13y ago> Jikes, http://jikes.sourceforge.net/ http://jikes.sourceforge.net/ That is not a JVM, that is a Java compiler. Surely you know the difference. > Oh and post Java 8, Hotspot might be replaced with Graal a new JIT done in Java, Good luck getting reasonable performance out of that. But even if the JVM decides to go that way, a JIT is only one part of a VM. The interpreter and the GC will take particularly bad perf hits if you try to write them in Java.
- swift 13y agoI agree that the GC is a bad fit but I don't see any reason to believe that the interpreter is a particularly bad thing to write in Java. Can you elaborate on your reasoning?
- justincormack 13y ago
- pron 13y agoYes, but only if you call 15 years of experience in both C/C++ and Java systems wishful thinking. And I'm talking big-ass, several MLOC, some soft and some hard realtime systems. But I guess some people must hold on to their beliefs, while some do extensive research (well, to be fair, it was government funded, so we had the means to write the same 2+ MLOC system twice, and we've had direct access to the Sun team working on their realtime Java project at the time). I guess you just don't have the data.
- haberman 13y ago> I guess you just don't have the data. Basically every piece of performance-critical open-source infrastructure (ie. what we can actually all see and evaluate) is written in C or C++. That is empirical data. You say that long-running servers that don't have startup cost constraints will perform better in Java, particularly when there is concurrency. Why then, is the entire web served by web servers written in C/C++ (Apache, IIS, nginx, LiteSpeed), mail servers written in C/C++ (Exim, Postfix, qmail, Sendmail, Microsoft), DNS servers written in C/C++ (BIND, PowerDNS), and database servers written in C/C++ (MySQL, PostgreSQL, Microsoft SQL Server, MongoDB, Riak)? You attempt to explain all this away, as if OS's, VMs, web browsers, etc (which you admit are better off written in C or C++) are somehow different from the applications you work on, and that somehow the Java you write in your applications would be hard to beat in C++. The only "data" you have offered is your own personal experience of working in the defense industry. A couple problems though. First of all you never write the "same" 2+ MLOC system twice, you'll always use the lessons gained from the first go at the second design. Something tells me you wrote the C++ version first. Your experience is also something that we can't see for ourselves, and involves lots of variables that we can't evaluate. It seems likely that your company didn't have a strong culture of best practices in C++, or maybe just weren't that good at it. Your C++ design might have had lots of opportunities for improvement that good C++ people would immediately recognize. It's not hard to write good and high-performance C++ when you have a good set of guidelines like the Google C++ style guide (http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...) and a solid set of core libraries, but without these it's easier to go astray. There's no doubt that Java's reasonable set of "batteries included" libraries makes this harder to screw up. I can say from my brief stint in defense that I was not super impressed. Everything was based around extremely heavy infrastructure like CORBA. There are lots of decisions like this that can skew the results you were getting.
- luikore 13y agoHotSpot is a large, complex application written in C++, it beats many metacircular VMs written in Java.
- pjmlp 13y agoWhich might be replaced by Graal after Java 8, a new JIT done in Java.