Here you can discuss ReactOS related topics.
Moderator: Moderator Team
5 posts • Page 1 of 1
It's a common misconception that using C++ automatically makes things slower than the equivalent code in C. There is a small overhead in the code, yes, but most of it is due to misusing virtual functions (indirect calls), and not being aware of the "this" pointer parameter implicit to instance methods. But since all this code was already COM code, which means it was implementing virtual functions (indirect calls to functions pointers through the vftable) even when using C, you have the same exact indirect calls and this pointer parameters as before! So there is no reason why the C++ conversion made anything slower at all, just easier to read.Oddjob64 wrote:I guess programing just got a lot more convenient, and the shell only got a little slower.
EDIT: If you were thinking that C++ code is harder to optimize by the compiler, keep in mind two things. First, that is only true for highly convoluted code that would also be hard to read by the programmer. Second, that ReactOS doesn't really use compiler optimizations yet, as they would introduce extra variables (as in external factors, not data containers) making debugging harder -- so it's not going to optimize the C code either.
Actually, not only do modern compilers generate code that is indistinguishable from C equivalent, I've written some programs in C++ that are faster than their C equivalent. I think this misconception arises from bad programmers attempting to use a lot of C++'s features without actually any concern for how they'll impact performance. A well-written C++ program can run extremely fast. Take Haiku for instance, I think it boots quicker than ROS (totally different architectures I know, but the point is it's fast).Oddjob64 wrote:I guess programing just got a lot more convenient, and the shell only got a little slower.
Users browsing this forum: DotBot [Crawler] and 2 guests