LWN.net Logo

Virtual functions have the same speed

Virtual functions have the same speed

Posted Jun 18, 2008 20:54 UTC (Wed) by khim (subscriber, #9252)
In reply to: Sometimes C++ is faster by johnkarp
Parent article: Converting GCC to C++

Remember - for a long, long time C++ compiler was C++-to-C compiler. Only one thing can not be efficiently implemented in C++-to-C compiler: exceptions. Everything else is just as efficient in C and in C++... except templates: where C++ compiler can generate series of functions automatically in C you either need horrible preprocessor cludges and/or code duplication.

Of course the same capability can be easily abused and lead to slower code!


(Log in to post comments)

Virtual functions have the same speed

Posted Jun 19, 2008 9:48 UTC (Thu) by nix (subscriber, #2304) [Link]

For a long, long time? I think the gap was something like three years between Cfront and G++.
It might have felt like a long time then, but it really wasn't. :)

10 years is long time in computing

Posted Jun 19, 2008 14:04 UTC (Thu) by khim (subscriber, #9252) [Link]

Cfront defined C++ for almost 10 years. Between 1983 and 1993 Cfront was the C++ compiler - and a lot of limitations of C++ back then were justified by the need to compile to C. It was reference implementation, it was used to define "standard C++" (people even used versions of Cfront to explain what type of language their compiler supported), etc. Eventually Cfront 4.0 was abandoned and after long period of instability (~5years) we've got consolidated standard and language was set in stone. But yes, for a long time needs of C++-to-C compiler defined the language.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds