3 ms·
I don't love java. Not at all. All my out of work coding is in other languages - primarily clojure since I can make use of the java I write at work. However, m
by bwanab 12y ago
I don't love java. Not at all. All my out of work coding is in other languages - primarily clojure since I can make use of the java I write at work.
However, my company has a risk management system that was written in C++. It's a system of large matrix operations that uses a lot of CPU and memory. Being one of the few neck beards at my company who had ever written C++, I was tasked with translating it to java. In order to guarantee correctness, I slavishly maintained the algorithms, classes, etc. This allowed me to compare intermediate results at each step, but obviously didn't allow for any improvements I might otherwise have done. I was hoping for a runtime differential of 2x over the C++ version which would have been adequate for our needs. I paid no attention to runtime performance, though, since correctness was the prime goal - we're talking about real money in the balance. Once I was satisfied with the numbers, I ran some performance tests. I was shocked to find the jave version ran 40% faster than the C++ version. And this was prior to performance enhancements that I was able to put into the java version added largely by the huge ecosystem that has built up around java/JVM programming.
So, yes, I don't like java, but it's hard not to respect it. Obviously, one example doesn't end the debate about performance, but I'll admit to having been shocked at this result.
- EpicEng 12y agoThere really isn't much difference when comparing code that does the same thing in roughly the same way. As you noticed, you can even get some performance freebies in managed world for a variety of reasons. However, that's not the point. You can tune your C or C++ to a much higher degree than you can managed code, and that's where they win.
- threeseed 12y agoThis has been covered ad naueseum. There are plenty of situations where both the C/C++ and Java sides of the fence will beat each other in benchmarks. Especially if you have average developers programming both platforms.
- EpicEng 12y agoYes, that "average developers" part is the important bit. Not sure what your point is here. The parent was talking about their experience in porting C++ code to Java, noting a performance improvement. In terms of performance, you don't use a language like C++ because it is going to be faster than everything else out there in all cases, you use it because you can eek out more performance than you can in using a language such as Java.
- bwanab 12y agoMy point was that the C++ version had been tuned over several years to get as much performance as it could. Replicating the C++ code in java wasn't the optimal strategy for performance in java, but it was the optimal strategy for getting the correct results. There are many optimizations I could have gotten by rewriting the java code in a manner that took better advantage of java's strengths, but alas the project is in other hands now....