473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Performance Question


I always assumed C++ would have better performance than C and, when I had
the choice, opted for C++.

Today, however, I was researching writing components for Linux and came
across this statement:

"KDE came first and came earlier to a mature state but C++ makes Qt and MICO
particularly inefficient for sophisticated applications. This was partially
corrected in version 2.0 and the coming 2.1."

The comparison was to GNOME, which is written in C.

My question is not application-specific, but general: Is C a more efficient
compiler than C++, offering better performance? Do the extra features of C++
slow down the execution of the final product?

Any insight is appreciated.

Thanks!
--

Tom Junior
to********@automateddesign.com

Automated Design Corporation
P: (630) 783-1150 F: (630) 783-1159
Jul 19 '05 #1
8 2447
Thomas Junior wrote:
I always assumed C++ would have better performance than C and, when I had
the choice, opted for C++.
....
Any insight is appreciated.


You can write inefficient code in any language.
Jul 19 '05 #2

"Thomas Junior" <to********@automateddesign.com> wrote in message news:Zy****************@newsread1.news.atl.earthli nk.net...

I always assumed C++ would have better performance than C and, when I had
the choice, opted for C++.
Why? The main goal for C++ is to make it NOT SLOWER than C.
My question is not application-specific, but general: Is C a more efficient
compiler than C++, offering better performance? Do the extra features of C++
slow down the execution of the final product?


C is not in general any more efficient. The C++ schemers took great pains to
not make things slower to do in C++ than they are in C. A lot of the odd features
of C++ reflect this. The idea is to not insert any performance penalties unless you
need the feature (for example, the fact that certain operations require polymorphic
classes, or that things aren't "virutal" by default).

Jul 19 '05 #3
Thomas Junior escribió:
"KDE came first and came earlier to a mature state but C++ makes Qt andMICO
particularly inefficient for sophisticated applications. This was partially
corrected in version 2.0 and the coming 2.1."


Nonsense. If C++ was the cause for inefficience, and considering that
KDE has not switched langauge, no new version can have corrected it,
partially or not.

Regards.
Jul 19 '05 #4
<>
I always assumed C++ would have better performance than C and, when I had
the choice, opted for C++.

Today, however, I was researching writing components for Linux and came
across this statement:

"KDE came first and came earlier to a mature state but C++ makes Qt and MICO
particularly inefficient for sophisticated applications. This was partially
corrected in version 2.0 and the coming 2.1."

The comparison was to GNOME, which is written in C.

My question is not application-specific, but general: Is C a more efficient
compiler than C++, offering better performance? Do the extra features of C++
slow down the execution of the final product?
</>

Virtual functions do slow down your program.
But otherwise your cpu might run hot :-). Don't
bother about it. Someone else told you that you
can write bad code in any language. Some even
support it. C++ doens't.

-X


Jul 19 '05 #5
Thomas Junior wrote:

I always assumed C++ would have better performance than C and, when I had
the choice, opted for C++.

[snip]

My question is not application-specific, but general: Is C a more
efficient compiler than C++, offering better performance? Do the extra
features of C++ slow down the execution of the final product?


C is (almost) a subset of C++. Whether a program that uses only C constructs
is compiled via a C or C++ compiler should have no impact on the execution
speed of the program.

C++ features that have no equivalent in C cannot be compared. Some people
say that virtual functions slow programs down. But what's the alternative?
A switch-statement that implements the same behaviour would probably
execute slower.

Some C++ features like inline methods and templates make it actually
possible to write faster programs than in C.

But you have to know your tools. It's easy to write slow programs in C++. I
ported a poorly programmed C++ program to Java. The Java version executes
much (!) faster than the original C++ code (and the Java version needs much
more memory too).

Best regards
Ralph
Jul 19 '05 #6
"Agent Mulder" <mb*******************@home.nl> writes:
[snip]
Virtual functions do slow down your program.

[snip]

Nonsense. My experience optimizing real world C++ is that virtual
hardly ever matters. If you *need* virtual, no C equivalent will
be faster. If you don't need it (which is much of the time), there
is usually a design reason (independent of performance) why you
should not be using it in the first place.

Jul 19 '05 #7
Thanks for the information, everybody. I was surprised by the statement in
the article, and wondered if there was something going on that I didn't know
about.

I have used virtual functions only for my Serial Communication class
(different chipsets), and did not notice an impact on speed. Of course, I
never bothered to clock it.

One person said to me this morning that KDE and GNOME are "pigs" due to "bad
programming." I asked him to elaborate on how it is programmed badly, but he
didn't. Maybe I'll download the source code for KDE and try and see if/where
they're sloppy. I am surprised by the resources it hogs up.

Thanks again for setting my mind at ease, everybody.

Tom Junior
"Ralph Peterson" <ra************@gmx.net> wrote in message
news:bj************@news.hansenet.net...
Thomas Junior wrote:

I always assumed C++ would have better performance than C and, when I had the choice, opted for C++.

[snip]

My question is not application-specific, but general: Is C a more
efficient compiler than C++, offering better performance? Do the extra
features of C++ slow down the execution of the final product?
C is (almost) a subset of C++. Whether a program that uses only C

constructs is compiled via a C or C++ compiler should have no impact on the execution
speed of the program.

C++ features that have no equivalent in C cannot be compared. Some people
say that virtual functions slow programs down. But what's the alternative?
A switch-statement that implements the same behaviour would probably
execute slower.

Some C++ features like inline methods and templates make it actually
possible to write faster programs than in C.

But you have to know your tools. It's easy to write slow programs in C++. I ported a poorly programmed C++ program to Java. The Java version executes
much (!) faster than the original C++ code (and the Java version needs much more memory too).

Best regards
Ralph

Jul 19 '05 #8
> Thanks for the information, everybody. I was surprised by the
statement in
the article, and wondered if there was something going on that I didn't know about.

I have used virtual functions only for my Serial Communication class
(different chipsets), and did not notice an impact on speed. Of course, I never bothered to clock it.
When doing I/O, the I/O itself is most likely the bottleneck. No amount
of optimization will help here as the time to transmit one byte over a
serial line probably takes much, much more time than a virtual function
call. Even if you would use a slower language (e.g. Java, Python), you
probably won't notice the difference. If you have a performance problem
you should always profile first to pinpoint the bottleneck. If the
application is I/O bound it is usually a good idea to look for a ways to
more efficiently use the I/O subsystem (e.g. sending large chunks of
data at once instead of one byte at a time or using non-blocking I/O).
One person said to me this morning that KDE and GNOME are "pigs" due to "bad programming." I asked him to elaborate on how it is programmed badly, but he didn't. Maybe I'll download the source code for KDE and try and see if/where they're sloppy. I am surprised by the resources it hogs up.


When developing something like KDE and GNOME there are other concerns
than performance as well, like for example flexibility, configurability,
extendabilty, maintainability...etc. Sometimes those issues conflict
with performance, and considering the ever increase power hardware it
might make sense to favor those concerns over performance. No doubt
those software packages carry also a fair share of historic bagage with
them.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Randell D. | last post by:
Folks, I have a Javascript performance question that I might have problems explaining... In PHP, better performance can be obtained dealing directly with a variable, as opposed to an element...
115
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical...
4
by: Martin | last post by:
I am using graphics as backgrounds for forms,buttons,labels etc. The question is: is it faster to load all graphics from files on app start or to use it embeded (places in editor during design)....
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
6
by: Mike | last post by:
Lets just say my app is done HOO HOO. Now, I'm accessing the database via a web service and one thing i noticed that my app is running real slow. When I first started working on the app is ran...
18
by: Rune B | last post by:
Hi Group I was considering using a Generic Dictionary<> as a value container inside my business objects, for the reason of keeping track of fields changed or added and so on. - But how...
5
by: Varangian | last post by:
Hi, I have a performance issue question? which is best (in terms of efficiency and performance, I don't care neatness in code)... building an ArrayList of Object Instances using SqlDataReader...
5
by: Markus Ernst | last post by:
Hello A class that composes the output of shop-related data gets some info from the main shop class. Now I wonder whether it is faster to store the info in the output class or get it from the...
5
by: toton | last post by:
Hi, I want a few of my class to overload from a base class, where the base class contains common functionality. This is to avoid repetition of code, and may be reducing amount of code in binary,...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.