> Both Rust and C++ can be substantially faster than C, for different reasons. C++ is better at capturing semantics in libraries. Rust knows more about what code is allowed to do, and can optimize accordingly.
People have been saying this for decades about various languages and C is still the standard for performance except for a few specific cases. How many more decades until we can consider this "sufficiently smart compiler" a myth?
Uhm, citation needed? Most of the most performance critical industries like game dev, high frequency trading, are primarily in C++, not C. Well written C++ tends to be more performant than C largely because there's just much less indirection in using templates than C equivalents (function pointers, void*, etc). And compilers are already smart enough to optimize out most C++ compile time abstractions.
Pretty much every benchmark I've ever seen, I provided one further down but here's another one: https://thenewstack.io/which-programming-languages-use-the-l... . Yes benchmarks can have many pitfalls but when literally all of them show the same unsurprising result (that more abstraction means worse performance) I think it's safe to trust them. Have you got a citation that shows c++ generally outperforming c?
> Most of the most performance critical industries like game dev, high frequency trading, are primarily in C++, not C
And I'd be willing to bet that the more critical components look a lot more like c than c++, not "modern c++".
> Well written C++ tends to be more performant than C largely because there's just much less indirection in using templates than C equivalents (function pointers, void*, etc)
Yes that's one advantage, it's one of the few specific cases where c++ performs better that I outlined. Even then _Generic_ in C can often give you a way to do the same (in an uglier way).
"Still the standard" among people who don't know that C++ is faster than C.
Fortran used to be the language for what we now call HPC. C was too slow. C++ is used now. This did not happen because Fortran got slower. Instead, C++ got faster.
The reasons are interesting. It turns out that to get faster Fortran, your compiler vendor has to code optimizations in the compiler. But in C++ you can code them in a library, and not wait on the attention of a compiler developer.
> C is still the standard among people who don't know that C++ is faster than C.
Care to share some examples? I know there are a few specific ones like sorting but every benchmark I've ever seen has c coming out ahead in most tests, especially when c++ features are used.
> Fortran used to be the language for what we now call HPC
Again that was a fairly specific case usually only seen in scientific applications.
From your other post:
> It is not unusual for a C++ or Rust program to be 30% faster than the C program it replaces. The reasons are worth studying.
Citation needed, this is so far off from every benchmark I've ever seen it's laughable.
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).
People have been saying this for decades about various languages and C is still the standard for performance except for a few specific cases. How many more decades until we can consider this "sufficiently smart compiler" a myth?