Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
D
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Jerry Coffin, post: 1401749"] [ ... ] Rather the opposite: C has virtually no opportunities to be faster than C++, but there are quite a few situations in which C++ not only can be, but more importantly, typically WILL be faster than C. Just for an obvious example, templates offer quite a few opportunities for generating code in-line that would normally involve calling functions through pointers in C. In many cases, you can expect the C++ version to be twice as fast as a bare minimum. C++ doesn't make a lot of fundamental improvements in these areas, but it does provide a few things that make them substantially less problematical. In C, you end up with some non-portable bits of code to do the bottom levels of these sorts of manipulations, and C++ doesn't really help in that area at all. C++ does, however, typically make a it a whole lot easier to integrate those non-portable bits into the rest of the code in a much more natural way. To use one of your examples, C++ doesn't directly support expanding multiplies -- you need to write some functions to do that. The difference is that in C, you end up with code something like: your_type x, y, z; set_val(&y, something); set_val(&z, something_else); ex_mul(&x, &y, &z); Whereas in C++, you can overload operators, to at least keep the rest of the code a bit more readable, so your multiplication looks like: your_type x, y = something, z = something_else; x = y * z; C++ provides basically that, but doesn't call it "a more capable preprocessor" -- instead, it calls it "templates". Depending on what exactly you mean by "complete abstracted" (for example) C++ may provide quite a bit more of what you want. Then again, it may not either -- for better or worse, your description is incomplete enough that it's almost impossible to give a definitive answer. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
D
Top