That’s just plainly false. A std::sort() for examples beats a qsort() easily. C just doesn’t have the tools to handle that kind of thing without a lot of manual code duplication.
The reason for not using C++ is simply that it’s a huge monster of a language, that makes it difficult to find common ground for a programming style. In C that is much easier as you have much less features to worry about. It is more verbose and error prone, but also more predictable and easier to review, as the code you see is what you get in the binary. In C++ can have a mountain of stuff hidden behind operator overloading, exceptions and other stuff, which makes it very difficult to reason about.
Aside from that I think C is more performant than C++ (indeed when you use the bells and whistles that C++ offers), you are comparing the libraries with each other.
The fact that the implementation of one random std::Sort is faster than the implementation of qsort() is comparing libraries, not the languages. You are comparing the algorithm of the Rust Sort with quicksort (which is obviously the qsort you are referring to.
I am certain there are sort implementations in C which outperform Rust.
Having said that, I immensely enjoy Rust because it forces me to think about the error handling and it does not give me the quirks of C/C++ (index out of bounds, memory corruption).
It’s not the libraries that make the difference, but that C++ templates allow you to write generic code that is easy to use and easy to optimized for the compiler due to having all the real data types readily available, while C has to fiddle with void* and function pointer to get similar flexibility, which are much harder to optimize, as none of the type information is there.
while C has to fiddle with void* and function pointer to get similar flexibility, which are much harder to optimize, as none of the type information is there.
I thought we were discussing speed, not ease of use?
If you manually hand optimize every line of code, C and C++ are identical. That’s a worthless discussion to have. The point is that you can write in C++ high level code that would require substantial code duplication to match the speed in C, as C just doesn’t offer the tools for that level of abstraction.
That’s just plainly false. A
std::sort()
for examples beats aqsort()
easily. C just doesn’t have the tools to handle that kind of thing without a lot of manual code duplication.The reason for not using C++ is simply that it’s a huge monster of a language, that makes it difficult to find common ground for a programming style. In C that is much easier as you have much less features to worry about. It is more verbose and error prone, but also more predictable and easier to review, as the code you see is what you get in the binary. In C++ can have a mountain of stuff hidden behind operator overloading, exceptions and other stuff, which makes it very difficult to reason about.
Aside from that I think C is more performant than C++ (indeed when you use the bells and whistles that C++ offers), you are comparing the libraries with each other.
The fact that the implementation of one random
std::Sort
is faster than the implementation ofqsort()
is comparing libraries, not the languages. You are comparing the algorithm of the Rust Sort with quicksort (which is obviously theqsort
you are referring to.I am certain there are sort implementations in C which outperform Rust.
Having said that, I immensely enjoy Rust because it forces me to think about the error handling and it does not give me the quirks of C/C++ (index out of bounds, memory corruption).
It’s not the libraries that make the difference, but that C++ templates allow you to write generic code that is easy to use and easy to optimized for the compiler due to having all the real data types readily available, while C has to fiddle with
void*
and function pointer to get similar flexibility, which are much harder to optimize, as none of the type information is there.I thought we were discussing speed, not ease of use?
If you manually hand optimize every line of code, C and C++ are identical. That’s a worthless discussion to have. The point is that you can write in C++ high level code that would require substantial code duplication to match the speed in C, as C just doesn’t offer the tools for that level of abstraction.
…so now we are discussing not speed again but ease of use.
Not everything with an R in it is faster than C. Read up about it. Everyone says so.
I’m out.