Re: is C necessarily faster than C++

urs@engineering.ucsb.edu (Urs Hoelzle)
Fri, 28 Apr 1995 19:08:16 GMT

          From comp.compilers

Related articles
[7 earlier articles]
Re: is C necessarily faster than C++ kohtala@laurel.trs.ntc.nokia.com (1995-04-09)
Re: is C necessarily faster than C++ rdo@elt.com (1995-04-10)
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)
[8 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: urs@engineering.ucsb.edu (Urs Hoelzle)
Keywords: C, C++, performance
Organization: University of California, Santa Barbara
References: 95-04-044 95-04-090
Date: Fri, 28 Apr 1995 19:08:16 GMT

Alistair McEwan <A.McEwan@lpac.ac.uk> writes:


>The SEL-HPC article archive has the following paper: Brad Calder,
>Dirk Grunwald, and Ben Zorn "Quantifying Behavioral Differences
>Between C and C++ Programs" , submitted to Journal on Programming
>Language and Design.


[snip]


>[It's an interesting paper. C and C++ programs are more different than I would
>have expected. -John]


Actually, I don't buy that - I believe the proper conclusion from the
paper is "current C++ compilers don't optimize C++ programs as well as
current C compilers optimize C programs". In other words, much of the
difference is in the compilers and not the languages.


Some empirical data to back up my conclusion appears in a paper titled
"Do object-oriented languages need special hardware support?". From
the abstract:


    Previous studies have shown that object-oriented programs have
    different execution characteristics than procedural programs, and that
    special object-oriented hardware can improve performance. The results
    of these studies may no longer hold because compiler optimizations can
    remove a large fraction of the differences. Our measurements show that
    SELF programs are more similar to C programs than are C++ programs,
    even though SELF is much more radically object-oriented than C++ and
    thus should differ much more from C.


In other words, if you have a compiler that uses OO-specific
optimizations, the resulting programs look a lot more like C. Current
C++ compilers are essentially C back ends with a C++ front end, and
they can't optimize (e.g.) virtual function calls, but if they were
more sophisticated, much of the difference seen by Calder et al may
disappear. So I think the jury is still out on whether C and C++
programs really are different.


(The paper is available from http://www.cs.ucsb.edu/~urs/oo-hardware.html.)


-Urs


----------------------------------------------------------------------------
Urs Hoelzle urs@cs.ucsb.edu http://www.cs.ucsb.edu/~urs
Computer Science Dept., University of California, Santa Barbara, CA 93106
(805) 893-3960 fax: (805) 893-8553
--


Post a followup to this message

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