Time and memory performance of C versus C++

  • Thread starter Generic Usenet Account
  • Start date
G

Generic Usenet Account

A lot of research has been done to prove that the contention that C
code is more efficient and more compact than equivalent C++ code is a
myth. My posting pertains to a slightly different aspect of this
debate. Here are my two questions:

1) Does anyone have any information on comparison of C and C++
software written for the ARM processor?

2) Are there any compiler and CPU dependencies that have to be
factored in while debating this issue? Or, is the issue more or less
settled for all compilers and all CPUs?

Thanks,
Kandregula Anil K.
 
V

Victor Bazarov

Generic said:
A lot of research has been done to prove that the contention that C
code is more efficient and more compact than equivalent C++ code is a
myth.

I'll take your word for it.
My posting pertains to a slightly different aspect of this
debate. Here are my two questions:

1) Does anyone have any information on comparison of C and C++
software written for the ARM processor?

2) Are there any compiler and CPU dependencies that have to be
factored in while debating this issue?

No. There is no point in debating this "issue" whatsoever. I am
sure that among my brethren in 'comp.lang.c' there will be somebody
with a different opinion, of course.
Or, is the issue more or less
settled for all compilers and all CPUs?

http://www.research.att.com/~bs/bs_faq.html#C-is-better Do you see
any mention of a platform or CPU?

V
 
I

Ian Collins

Generic said:
A lot of research has been done to prove that the contention that C
code is more efficient and more compact than equivalent C++ code is a
myth. My posting pertains to a slightly different aspect of this
debate. Here are my two questions:

1) Does anyone have any information on comparison of C and C++
software written for the ARM processor?
One can write piss poor inefficient code in either language, or one can
write elegant efficient code in either. Programmers write code, not
compilers, so there isn't anything to study or discuss.
 
E

ediebur

One can write piss poor inefficient code in either language, or one can
write elegant efficient code in either. Programmers write code, not
compilers, so there isn't anything to study or discuss.

These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?
 
J

jameskuyper

(e-mail address removed) wrote:
....
These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?

As our computers get more powerful, the problems we try to solve with
them get more difficult. If you have a program which takes 10 days to
run on a 3-GHz machine with 1GB RAM, an algorithm change that causes a
speed-up by a factor of 2 is going to look pretty sweet.

Truly elegant code is easier to understand and maintain; with
programmer time costing so much more than CPU time, elegance is
getting steadily more important, not less.
 
T

Tor Rustad

Generic said:
A lot of research has been done to prove that the contention that C
code is more efficient and more compact than equivalent C++ code is a
myth. My posting pertains to a slightly different aspect of this
debate. Here are my two questions:

1) Does anyone have any information on comparison of C and C++
software written for the ARM processor?

Platform or C++ specific questions, are off-topic in c.l.c
2) Are there any compiler and CPU dependencies that have to be
factored in while debating this issue? Or, is the issue more or less
settled for all compilers and all CPUs?

Compiler or CPU specific questions, are off-topic in c.l.c
 
J

jacob navia

These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?

This is the attitude that leads to shitty and bloated programs.

Since shitty programs are the way to go (they cost less effort
to write, they lead to the user buying a new machine, they make the
economy go round) you are right of course.

Let's write the new computer language: C# running in a virtual
machine written in GWBASIC.
 
S

Stephen Sprunk

Generic Usenet Account said:
A lot of research has been done to prove that the contention that C
code is more efficient and more compact than equivalent C++
code is a myth.

Of course it's a myth. If you write equivalent code, the performance will
be nearly identical, since AFAIK all interesting compilers share the code
generation engine across both C and C++ modes.

OTOH, C++ allows you to write a different style of code that can't (easily
or efficiently) be written in C. C++'s additional features to support that
style also tend to be the features that are either particularly slow to
execute or encourage programmers to write slow code -- but they also tend to
make the code code faster to write and easier to understand and debug.
Depending on the purpose and use of the code, that may or may not be a smart
trade-off.

(Specifically, templates and classes can save massive amounts of programmer
time -- but they also hide from the programmer what's going on under the
hood so that he/she may not realize that a simple-looking statement may be
hundreds of times more complex than a slightly more-complex-looking
statement.)
My posting pertains to a slightly different aspect of this debate.
Here are my two questions:

1) Does anyone have any information on comparison of C and C++
software written for the ARM processor?

The processor type has nothing to do with it.
2) Are there any compiler and CPU dependencies that have to be
factored in while debating this issue? Or, is the issue more or less
settled for all compilers and all CPUs?

The latter, at least in the sense it's "settled" that your question is
either nonsensical or irrelevant.

S
 
I

Ian Collins

*Please* don't quote signatures
These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?
Do you have any pride in your work?
 
M

moschops

These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?


Hey, that's great! Where can I pick up one of these 3ghz 1GB RAM
computers? I need it to be about 3 cm by 3 cm all in, drawing no more
than one amp of current and using about 10W of power, with a JTAG port
on board.

What's that, you say? There's no such thing? Well then, I guess I'll
have to use whatever I can get in that size, current and power
limitations and just do some damned elegant coding to get it to do what
I need.

Lift your head from the keyboard once in a while, chum. There's more to
computing that desktop PCs.

'Chops
 
J

jacob navia

moschops said:
Hey, that's great! Where can I pick up one of these 3ghz 1GB RAM
computers? I need it to be about 3 cm by 3 cm all in, drawing no more
than one amp of current and using about 10W of power, with a JTAG port
on board.

What's that, you say? There's no such thing? Well then, I guess I'll
have to use whatever I can get in that size, current and power
limitations and just do some damned elegant coding to get it to do what
I need.

Lift your head from the keyboard once in a while, chum. There's more to
computing that desktop PCs.

'Chops

Even in desktop's PCs that philosophy is utterly WRONG and leads to
software that takes gigabytes to do the simplest thing. Of course if you
have 2GB or 4GB of memory it doesn't matter... UNTIL YOU WANT TO RUN
A DOZEN OF THOSE!
 
M

Malcolm McLean

moschops said:
Hey, that's great! Where can I pick up one of these 3ghz 1GB RAM
computers? I need it to be about 3 cm by 3 cm all in, drawing no more than
one amp of current and using about 10W of power, with a JTAG port on
board.

What's that, you say? There's no such thing? Well then, I guess I'll have
to use whatever I can get in that size, current and power limitations and
just do some damned elegant coding to get it to do what I need.

Lift your head from the keyboard once in a while, chum. There's more to
computing that desktop PCs.
Yes, but typically embedded processors do jobs which are utterly trivial.
Like turn on a few lights in a washing machine.
 
F

Flash Gordon

Please don't quote sigs, the bit typically after the "-- ".
These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?

You have a 3GHz processor with 1GB RAM in your microwave oven? Do you
think efficiency does not matter if you have a few hundred simultaneous
users on your server? Just to name two of the many reasons why
needlessly inefficient code is a problem.
 
M

moschops

Malcolm said:
Yes, but typically embedded processors do jobs which are utterly
trivial. Like turn on a few lights in a washing machine.

Typically. But, of course, some of them do things that are far from
trivial. Hacks who make comments about how there's no need for elegance
in coding can do the washing machines, and the rest of us can do the
non-trivial stuff.

'Chops
 
F

Flash Gordon

Malcolm McLean wrote, On 09/11/07 21:54:
Yes, but typically embedded processors do jobs which are utterly
trivial. Like turn on a few lights in a washing machine.

Or image recognition in real time, of performing 42 simultaneous
correlation calculations to detect signals well below the noise
threshold and extract information off them that is encoded in variations
of the bit width and simultaneously calculate the relative velocity of
the receiver and transmitter based on the dopler shift. Or perform real
time MPEG compression. Or...

Well, suffice to say that vast numbers of embedded processors, including
embedded processors in the computer I am using, the TV I am watching, my
DVD player and my surround sound decoder are doing complex tasks
involving a lot of computation.
 
C

cr88192

jacob navia said:
This is the attitude that leads to shitty and bloated programs.

Since shitty programs are the way to go (they cost less effort
to write, they lead to the user buying a new machine, they make the
economy go round) you are right of course.

Let's write the new computer language: C# running in a virtual
machine written in GWBASIC.

or an OS that makes a 4.4 GHz machine with 2GB ram drag along slowly as crap
goes in and out of swap, where half my software doesn't work right, where
even basic crap that existed before is gone, where the web browser crashes
if one even looks at it too hard, where one discoveres that one app can
cause another to crash, and where one can only have a few different apps
open before the OS starts going insane and breaking...

in this OS we can pretend that local file copies are going over the LAN or
something given how fast they are going...

good job that...


it was enough in time to cause me to install go over to using XP on this box
(even though it came with said OS in question, which is all so theoretically
newer and better...). then one (eventually) discoveres certain other
annoyances, namely that certain OEMs had the amazing idea of no longer
making XP drivers for some of their hardware, causing the user to go dig
around for something that still works...

like, what if someone decides to go and buy one of their newer MOBOs, and
has no intention to use said newer OS, only to find that the chipset drivers
lack certain key components (like, for example, the onboard sound)
apparently only available if one uses said newer shinier OS...

and why is it that all this stuff has not long since become defacto
standardized anyways?... I remember a short time when damn near every
soundcard around would work if one just used SoundBlaster drivers...

looks to me like a great conspiracy between the HW vendors and this certain
OS vendor...


this is the face of the future it seems...

or such...
 
E

ediebur

Typically. But, of course, some of them do things that are far from
trivial. Hacks who make comments about how there's no need for elegance
in coding can do the washing machines, and the rest of us can do the
non-trivial stuff.

'Chops

Jeez, I just brought it up as a topic for discussion, didn't mean for
anyone to get nasty
 
R

red floyd

Malcolm said:
Yes, but typically embedded processors do jobs which are utterly
trivial. Like turn on a few lights in a washing machine.

To quote Pauli.... This isn't right. It isn't even wrong.

Lets see.... avionics, video codec, audio codec, other multimedia,
printer engine....

Yeah, those are just turning on a few lights.
 
J

Juha Nieminen

These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?

Ever played a modern computer game with millions of polygons per
level, even tens of thousands of polygons visible at the same time,
complex physics, etc? Do you want to play that kind of game at 0.5
frames per second or at 30 frames per second in your 3GHz computer?
 
D

Duane Hebert

These days with 3ghz computers with more than 1 gbyte RAM what is so
important about elegant, efficient code?


Missed the bit from the OP about Arm did you? Sort of topical
for me since I've spent the last two days trying to crowbar Chinese
fonts into an XScale Arm product.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top