You would, if you were scrupulous, compile your C program with a C++ compiler to prove absolutely that C cannot be faster than C++, before going on to make the C++ version faster, using features that do not exist in C. .
Your benchmarks demonstrate only that it is possible to write slow code in any language, even a fast one.
It would be easy enough to make the C programs equally slow, still proving nothing about either language.
Are you trolling? I Honestly don't know where to start with that post.
> You would, if you were scrupulous, compile your C program with a C++ compiler to prove absolutely that C cannot be faster than C++
If my program compiles, which is a big if because c is not a subset of c++, all it would demonstrate is which compiler is better. A c program being compiled with a c++ compiler doesn't gain any type information, it can't make any assumptions that the C compiler couldn't.
> before going on to make the C++ version faster, using features that do not exist in C.
Which features? It's certainly not going to get faster by throwing in OO abstractions and virtual methods.
> Your benchmarks demonstrate only that it is possible to write slow code in any language, even a fast one.
Then show me some better ones, so far I've provided more examples supporting your point than you have.
If you compile any C program with a C++ compiler (possibly making trivial changes to account for gratuitous language divergence) you will find, for reasons you note yourself, that it runs at exactly the same speed. NOT, let me emphasize here because this seems to be difficult to process, ever slower than C. Therefore, (try to follow this) C is never faster than C++.
So, it is at best foolish to insist that C can ever be faster than C. The falsehood is trivially exposed.
If you think that C++ is about OO gook and virtual functions, an education awaits. But not here.
You don't need a benchmark. Given any C code, you can make a C++ code that runs as fast (just use the same code). This proves that C++ is at least as fast as C.
From there, maybe you could use C++ features to improve the speed (and then C++ is faster) or you could not (and then they have the same speed).
Your benchmarks demonstrate only that it is possible to write slow code in any language, even a fast one.
It would be easy enough to make the C programs equally slow, still proving nothing about either language.