In fact, C ++ has the ability to be faster than c in many ways, due to its ability to support many timetime constructs, such as expression patterns. For this reason, C ++ library libraries are generally much more optimized than c, associated with fewer time series, reversal cycles, etc. With new C ++ 0x functions, such as variant templates, the printf function, for example, can be much faster and typical than the version implemented in c. It’s mine you can even draw on the interfaces of many c constructs and evaluate some of their arguments (for example, string literals).
Unfortunately, many people believe that c is faster than C ++, because many people use OOP to mean that all relationships and use should occur through large inheritance hierarchies, virtual dispatch, etc. This led to some early comparisons being completely different from what is considered good use these days. If you use virtual dispatching where appropriate (for example, as file systems in the kernel, where they build vtables via function pointers and often mostly build C ++ in c), you will not pessimize from c and with all the new functions may be significantly faster.
Not only speed can be improved, but there are places where implementation will benefit from better type safety. There are common tricks in c (for example, storing data in void pointers when they should be shared) that provide security like breaks and where C ++ can provide strong error checking. This will not always translate through interfaces to the c library, since they have fixed typing, but it will definitely be useful for library developers and may help in some places where it may be possible to extract additional information from calls by providing as-if interfaces (for example , the interface that void * accepts can be implemented as a common interface with the concept, make sure that the argument is implicitly converted to void *).
I think this would be a great test of the power of C ++ over c.
source share