1
$\begingroup$

I took programming lecture it was about C/java and how to build compilers, so I wanted to know.

As far I see, languages like Java/C# are developing their virtual machine CLR/JVM with good base and are improving repeatedly to increse its speed and their JIT compiler.

So I was wondering, is it possible in near future that languages such as JAVA or C# to be faster than C++ ? Or is it logically impossible ?

$\endgroup$

1 Answer 1

3
$\begingroup$

It is impossible for one language to be faster than another language, period.

A programming language is a set of abstract mathematical rules and restrictions. It is an idea. A piece of paper. You cannot run a language, therefore, you cannot measure its performance.

What you can do is run a particular piece of code written in one language using a particular version of a particular implementation of that language with a particular set of command line flags in a particular environment and compare its performance to a different piece of code written in a different language run with a different version of a different implementation configured with a different set of flags in a different environment.

But with all those differences, it will then be impossible to tell which of all of those differences actually caused the difference in performance. Was it the different benchmark programs? The different configuration options? The different versions? The different implementations? The different environments? Was the difference in performance caused by the language or by the quality of the implementations? Was it maybe caused by the difference in how much money was invested in optimizations?

I am willing to bet that for every set of environments and implementations that you can present me where language A is faster than language B, I can find a different set of environments and implementations where for the same two pieces of code, language B outperforms language A.

For example, there are Java implementations that are really fast. There are C++ implementations that are really slow. All I need to do is run my benchmarks using those two implementations, and I will have "proven" that Java is much faster than C++.

In the YARV Ruby VM, the Hash class is implemented in C. In the Rubinius Ruby VM, the Hash class is implemented in Ruby. Benchmarks that make heavy use of Hashes run faster on Rubinius than on YARV. Does that prove that Ruby is faster than C?

$\endgroup$
1
  • $\begingroup$ ah thanks for the clarification. $\endgroup$
    – MR.-c
    May 13, 2021 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.