Re: is C necessarily faster than C++

quanstro@hp-demo1.minerva.bah.com (goon)
Fri, 28 Apr 1995 19:15:29 GMT

          From comp.compilers

Related articles
[8 earlier articles]
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)
Re: is C necessarily faster than C++ calder@mumble.cs.Colorado.EDU (1995-05-09)
[7 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: quanstro@hp-demo1.minerva.bah.com (goon)
Keywords: C, C++, performance
Organization: world orginization of anarchists
References: 95-04-044 95-04-123
Date: Fri, 28 Apr 1995 19:15:29 GMT

ruiter@ruls41.fsw.leidenuniv.nl (Jan-Peter de Ruiter) writes:


      However, in practice, because every complex object has both a constructor
      and a destructor, there is an additional function overhead cost.


      It is said that these can be inlined, but not all compilers do so,
      and it's not always possible either. More importantly, constructing
      and destructing local complex objects takes a lot of malloc-ing and
      free-ing. Experienced C programmers having to write efficient code
      usually avoid many calls to malloc by fooling around with pointers
      and keeping track of allocation themselves.


?! I find that experienced c programmers worry more about correctness
and simplicity (i.e. how long is it going to take to code this)
than speed.


it's the inexperienced programmer who worries a lot about speed
before it's known to be an issue.


      Take a C program that manipulates strings. Experienced C programmers
      will keep track of what string resides where, avoiding unneccesary
      copying. Now using a good string library in C++ relieves you of the
      burden of keeping track of your memory, but it adds the overhead of
      constructing and destructing them.


You can write constructor/destructor based c libraries
you can write pointer-based c++ libraries.


I don't agree with "c is so" and "c++ is elseways":


(Very) theoretically, every c program is also a c++ program
that gets more warnings when run through the compiler. So
c libraries can be used as c++ libraries.


I think the difference between c and c++ usage is mostly cultural.
--


Post a followup to this message

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