Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: C++ more efficient than C?

Reply
Thread Tools

Re: C++ more efficient than C?

 
 
Ian Collins
Guest
Posts: n/a
 
      04-06-2008
copx wrote:
>
> So C coders who care about efficiency should switch to C++?
>

Are you trying to start a flame war?

In some instances (typically where inlined function templates can
replace functions with void* parameters) C++ will be faster. Because
the C++ standard library incorporates the C standard library, C++ code
should never have to be slower.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-06-2008
copx wrote:
> "Ian Collins" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
>> copx wrote:
>>> So C coders who care about efficiency should switch to C++?
>>>

>> Are you trying to start a flame war?

>
> No, if that were my intention, I would have crossposted this to
> comp.lang.c++ for maximum effect!
>

Ho No! Please don't we've had another Java troll stirring things up
over there!

>> In some instances (typically where inlined function templates can
>> replace functions with void* parameters) C++ will be faster. Because
>> the C++ standard library incorporates the C standard library, C++ code
>> should never have to be slower.

>
> Of course, but the interesting claim here is that you should NOT use C style
> code but modern C++ abstractions, because they are not only more readable
> and expressive, but also more efficient. The second part (they actually
> being more efficient) was news to me.


The only place C++ will win the performance race is where the *language*
offers an advantage, which is why sorting is often cited as an example.
A lot of C++ code (including libraries) is written either in the C
subset of C++ or using constructs that can be implemented equally well in C.

> Well, the inlined function templates superiour to void * functions thing
> certainly makes sense. Maybe I should finally "move on" after all.
> However, I compiled both examples with the current version of GCC (on
> Win32-x86), and there is at least one area where C won: code size. The size
> difference between the resoluting executables was grotesque: C code => 5KB,
> C++ code => over 400KB! (both binaries optimized for size and stripped!)
>

That'll be all those inlined templates! Seriously, there is nearly
always a performance/size trade-off. Not always this big though.

--
Ian Collins.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: C++ more efficient than C? bc1891@googlemail.com C++ 85 04-21-2008 09:23 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com Java 0 03-06-2008 08:11 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
why is double more efficient than float ? maadhuu C Programming 14 09-17-2005 07:17 AM



Advertisments