Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a real-world benchmark of Java vs C++? [closed]

Before I get to the question, please note what this question is NOT:

  • Is Java slower (or faster) than C++?
  • Why is Java slower (or faster) than C++?

This question doesn't solicit opinions, it solicits facts -- numbers.

Many benchmarks, like https://days2011.scala-lang.org/sites/days2011/files/ws3-1-Hundt.pdf or http://benchmarksgame.alioth.debian.org/ test something synthetic, like Mandelbrot, or at best a tiny part of a real program, like array sorting. Naturally, that won't produce representative numbers like benchmarking an entire app would.

So, is there a benchmark that uses a real, complete app like:

  • a notes app or word processor
  • a maps app like Google Maps
  • an email client
  • a web server

It has to be something you use everyday -- a complete app, and not a tiny portion of one, like binary trees or sorting arrays.

Any measurement of performance will do, whether latency or throughput. Thanks.

like image 530
Kartick Vaddadi Avatar asked Nov 27 '22 20:11

Kartick Vaddadi


1 Answers

The simple answer is no, and I'm tempted to say that it isn't even possible, at least economically. To do so, you'd have to implement the same application twice, with two different teams, in parallel at the same time. And even then: how much of the difference is due to the language, and how much to the relative competence of the teams, etc.

In the end, you cannot compare the performance of "languages". At best, you can compare the performance of language implementations, when used by specific programmers for specific tasks. Which, in a certain sense, is all that interests you: you have to implement a specific application with the programmers you have and the language implementations which are available to you. Even if there were a comparison such as you seek, it wouldn't help you much, because you'll be implementing a different application with a different group of programmers (who likely have a different skill set than the programmers who implemented the benchmark). And while different languages do have characteristics which make optimization more or less difficult, on the whole, in larger applications (as opposed to synthetic benchmarks), these tend to be outweighed by large considerations, or offset by other characteristics which also affect optimizing: the pointer semantics of C/C++ are a bane to optimizers; on the other hand, optimizing Java will require extensive boxing, which isn't trivial either. (FWIW: the easiest language to optimize is probably Fortran. Not because of anything intrinsic in the language, but because researchers have been working on it the longest, and many of the necessary optimization techniques have become mainstream.)

If you're really concerned, you'll have to have the programmers available to you write their own benchmarks, based on patterns in your application, and implemented by your programmers.

And finally: a lot of real apps, including things like a word processor, an email client or a web server are IO bound; their performance depends more on the speed of IO than anything else. (For most of the large scale servers I've worked on, we didn't even bother turning on the optimizer. Despite the fact that they were time critical; the CPU time just didn't have an impact.)

like image 112
James Kanze Avatar answered Dec 05 '22 11:12

James Kanze