21 ms·
There isn't anything you can make the processor do in C that you cannot also make it do in C++ (if I am not mistaken!) Given that, C will only appear faster if
by adgasf 8y ago
There isn't anything you can make the processor do in C that you cannot also make it do in C++ (if I am not mistaken!) Given that, C will only appear faster if you are not using C++ to its full potential. This might be because you don't know what you're doing or because the C++ language makes it unreasonably awkward. Most articles I have read like this are the former, unfortunately.
- faissaloo 8y agoNo, C will be faster because you have more control, in the same way that Assembly will always be faster than C.
- gmueckl 8y agoC++ allows you to write code that is equally expressive as C. It is no longer true that every valid pice of C is also valid C+++, but the deviations are purely minor syntactical differences. I know no C construct for which a C++ counterpart does not exist. Please enlighten me if you have an example.
- kccqzy 8y agoVLA.
- gmueckl 8y agoOkay, this is true. Using alloca directly is not a good alternative.
- mikulas_florek 8y agohttps://en.cppreference.com/w/c/language/restrict https://en.cppreference.com/w/c/language/restrict
- gmueckl 8y agoReplace it with __restrict and you're fine.
- mikulas_florek 8y agonot standard c++
- maximilianburke 8y agoDesignated initializers. (yet)
- mikulas_florek 8y agothat's just syntactic sugar