Re: is C necessarily faster than C++

"Patrick C. Beard" <beard@cs.ucdavis.edu>
Fri, 28 Apr 1995 19:25:01 GMT

          From comp.compilers

Related articles
[9 earlier articles]
Re: is C necessarily faster than C++ tmb@netcom.com (1995-04-20)
Re: is C necessarily faster than C++ ruiter@ruls41.fsw.leidenuniv.nl (1995-04-20)
Re: is C necessarily faster than C++ cliffc@crocus.hpl.hp.com (1995-04-17)
Re: is C necessarily faster than C++ gardner@pink-panther.cs.uiuc.edu (1995-04-28)
Re: is C necessarily faster than C++ urs@engineering.ucsb.edu (1995-04-28)
Re: is C necessarily faster than C++ quanstro@hp-demo1.minerva.bah.com (1995-04-28)
Re: is C necessarily faster than C++ beard@cs.ucdavis.edu (Patrick C. Beard) (1995-04-28)
is C necessarily faster than C++ ka@socrates.hr.att.com (1995-04-28)
Re: is C necessarily faster than C++ jplevyak@pink-panther.cs.uiuc.edu (1995-04-29)
Re: is C necessarily faster than C++ tmb@netcom.com (1995-04-29)
Re: is C necessarily faster than C++ jdean@pysht.cs.washington.edu (1995-05-09)
Re: is C necessarily faster than C++ calder@mumble.cs.Colorado.EDU (1995-05-09)
Re: is C necessarily faster than C++ schow@bnr.ca (stanley (s.t.h.) chow) (1995-05-09)
[6 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: "Patrick C. Beard" <beard@cs.ucdavis.edu>
Keywords: C, C++, performance
Organization: Computing Research Group
References: 95-04-044 95-04-129
Date: Fri, 28 Apr 1995 19:25:01 GMT

Dave Hayden, dave@edo.ho.att.com writes:
>Although C++ can be just as fast as C, it can also be horribly slow.
>For example, the Mac compilers that I've seen must search through tables
>to find a virtual function. The result is 20 - 100 instructions of overhead
>just to call a virtual function. Also, constructors and destructors
>can add lots of wasted time.


None of the "C++" compilers for the Mac do this. They all use virtual
function tables with constant time dispatching. THINK C's objects
used the search technique you mention, but it wasn't full C++.


Constructors and destructors can also be extremely worth the time
they take. For example, complex networks of objects can be created
and destroyed with much less chance for error than when not using
constructors/destructors.


However, you might not want to have a virtual destructor in your
Complex number class. It all depends on the application.


// author: Patrick C. Beard
// organization: Computing Research Group
// e-mail: beard@cs.ucdavis.edu
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.