(no title)
7steps2much | 3 years ago
I can guarantee you that this "old tech" was coded with more thought invested into it than at least half of these "modern libraries".
Well written C code can easily blow a C++/Rust application out of the water.
7steps2much | 3 years ago
I can guarantee you that this "old tech" was coded with more thought invested into it than at least half of these "modern libraries".
Well written C code can easily blow a C++/Rust application out of the water.
dralley|3 years ago
7steps2much|3 years ago
Of course, for the sake of completeness it should be noted that:
> With the run-time checks disabled and the restrictions loosened, Rust presents a performance indistinguishable from C. [1]
Though I believe my original statement to hold none the less, as disabling these restrictions disables (amongst other things) bound and overflow checking, which is one of if not the major selling point of rust.
As for C++ depends on the features that one uses. If one writes "just what one could do in C" then the machine code produced by the compiler will be exactly (almost) the same. This is due to the fact that many c++ features are only compiler relevant but compile to (almost) the same instructions as code.
However, I would once again raise the question I did above with rust: If we use little to no c++ features then can we distinguish that codebasse from a c codebase in any meaningful way? But assuming we write idomatic code we will have the c++ code behaving somewhat slower due to factors such as:
- automatic collections/object allocation. Datastructures growing "on demand" do in general perform slower than a comparable "none automatic" datastructure increased in larger chunks by hand (using malloc/etc. in C). While this is an implementation detail admittedly, I believe the libstdc++ does not use chunking, though I would not swear on that. - strings. While no doubt a big upgrade from \0 terminated char sequences idomatic strings in C are less efficient. Especially when it comes to concatenating or manipulation of said strings. In addition it may lead to memory fragmentation, though this should be an afterthought most of the time.
In general the performance difference of C++/C comes down to "hidden" code. While by no means large, assuming software such as the dns root servers which are running essentially 24/7 and will most likely continue doing so for quite a while even small differences in performance will add up.
Admittedly however my original statement of
> Well written C code can easily blow a C++/Rust application out of the water.
May not have been well formulated. It would have been better to split the statement and be more specific about the individual performance differences in regards to rust/c++ instead of bunching them together.
[1]: https://dl.acm.org/doi/pdf/10.1145/3551349.3559494