Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Why do people still use C instead of C++ ?

Reply
Thread Tools

Why do people still use C instead of C++ ?

 
 
Laurent Deniau
Guest
Posts: n/a
 
      12-28-2008
On 28 déc, 05:54, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
> On Dec 27, 6:58*pm, Laurent Deniau <(E-Mail Removed)> wrote:
>
>
>
> > On 27 déc, 20:24, Rolf Magnus <(E-Mail Removed)> wrote:

>
> > > Laurent Deniau wrote:
> > > >> Now, are you saying that, as a conclusion, C++ is better than C
> > > >> (because there's no difference in performance, yet C++ has more
> > > >> features), but programmers still use C just because they're used to?

>
> > > >> And in that case, all newbies should be advised to learn C++, right?

>
> > > > C++ is not a super set of C

>
> > > It can be used as one.

>
> > > > and is much more complex which means that "average" C++ programmers may
> > > > have some difficulty to predict the behavior of their code. There is also
> > > > things which are "easy" to do in C and nearly impossible in C++.

>
> > > Which would that be? Most C code can be put through a C++ compiler with only
> > > a few minor changes.

>
> > I would be very interested (honestly) by the "few minor changes" to
> > apply to COS (C Object System) to be able to compile it with a C++
> > compiler. It compiles with a C99 compiler or even with a C99
> > (standalone) preprocessor and a C89 compiler.

>
> I had wanted to take a stab at it, but:
>
> 1. COS is not actually available on SourceForce except through CVS.
> Not very convenient.


Right (sorry for this), I am working on the tarball for next week. I
still need to improve install/uninstall targets of makefiles and some
minor things.

> 2. The COS Makefiles do not build. It appears you used something like
> autoconf but did not actually include a configure script in CVS.


It's only makefiles, but it requires gmake (tested with gmake 3.81).
There is no configure or so to run.

> The
> compilation instructions in your README are incorrect. After looking
> for the source of the problem and seeing the number of environment
> variables that were not defined (e.g. everything checked for by the
> 'prologue' include file), I gave up.


COS is actually tested on MacOSX and Linux since I don't have access
to other architectures. Makefiles are not portable to Windows unless
you install cygwin or equivalent. The config file are not yet done for
it. Maybe you tried on a yet unsupported architecture? The structure
of the makefile is similar to the makefiles of POCO++.

> 3. While it's certainly an interesting project, you seem to have
> reinvented a serious wheel. If a developer used COS in an application,
> then more likely there were better tools for that developer's job than
> C in the first place.


Like? AFAIK, the COS features are unique in a single "language". The
closest would be a mix between Objective-C, CLOS and Dylan.

> > > > I have been using C++ from 1989 to 2006 and switch back to C for this
> > > > reason once I found the programming techniques that fit my needs. Before
> > > > doing the switch, I used (and abused) templates and I studied in depth the
> > > > C++ object model to understand what I could(n't) do. As already said, the
> > > > best is to use the language that fits your needs.

>
> > > I can see uses of templates even down to the smallest microcontroller
> > > devices (and have actually used them there).

>
> > I didn't say that you can't or it's useless. I just say that I tried
> > to implement some features (e.g. multi-methods, messages) which I
> > consider today to be very important in a language and failed to do it
> > in C++ while it was relatively easy to do in C.

>
> Why did you fail to do it in C++? What specific problems are you
> referring to?


- COS needs a C99 preprocessor. Maybe the next release of C++ will get
the equivalent.

- the object model is completely different from the C++ one and it's
rather difficult to combine the two.

- multi-method would have to deal with lookup, overloading and
templates. This is far beyond the capabilities of my macros.

> Issues with... type checking or something?


no, it's not an issue. C and C++ are close enough on that point. In
particular, all COS objects are structures, which make the objects
system strongly statically typed in both languages except that C++
would provide subtyping while C doesn't.

> It's fairly
> straightforward to compile C with a C++ compiler; most of the changes
> involve adding explicit casts and changing names that are now C++
> keywords (e.g. "class").
>
>
> Most issues are described here:http://docs.hp.com/en/92501-90029/ch01s03.html
> , search the page for "changing your C programs to C++".


This paper is about C89. Nevertheless, I do not use C++ keyword (eg.
self and not this for my receivers).

> C does not have support for multi-methods, nor does C++, in both
> languages you have to emulate them some other way. I can certainly
> imagine various schemes for implementing them in C++; they are
> probably similar to what you did in C.


Probably not. In C++ you must stay compliant with the existing. Issues
are those already mentioned, but also management of multi and virtual
inheritance, portability of "generic" pointers to (member) functions
and template functions, support for meta-classes with the unicity of
the ids (not ensured by C++), etc...

> What is it about C++ that you
> found to be a barrier to implementing these? There are plenty of ways
> to do runtime type checking in C++...


Yes. But the "normal way" in C++ would be double (or more) dispatch on
top of the C++ object model. This is not easy to automatize nor
efficient (this is the way multijava works). The dispatcher of COS is
as fast as C++ virtual member functions on Linux 64bits with gcc4.

> Same deal with messaging systems, which are just as trivial to
> implement in C++ as they are in C.


Not exactly. Dispatch is not the all story and it's far beyond this
thread to explain the all story. In order to get an idea, you can
still read the slides

http://cos.cvs.sourceforge.net/viewv...des-cos.pdf.gz

or the paper (longer, obsolete, but gives an idea)

http://cos.cvs.sourceforge.net/viewv...verview.pdf.gz

> Jason
>
> P.S. Just to set the tone, I don't have a problem with C at all, and
> still use it for some applications.


Neither me I am just looking for the right tool for my need
(numerical computation & simulation).

> Mostly I'm wondering if you've
> actually been having issues with C++, or if the issues are because
> your implementation attempts failed for other reasons.


This is more related to C++. In fact you can also have a look at the
second half of the presentation once you have read the COS
presentation. This is a kind of "motivation for COS".

http://cos.cvs.sourceforge.net/viewv...-design.pdf.gz

You can also google about "strong typing vs strong checking" to get an
idea why I changed my mind and introduce more dynamics in my code.

a+, ld.
 
Reply With Quote
 
 
 
 
Matthias Buelow
Guest
Posts: n/a
 
      01-02-2009
Lawand wrote:

> Shouldn't C++ have replaced C? even when developing an OS kernel or
> such sensitive software.


Maybe it's because "OS kernel or such sensitive software" is often the
domain of hackers or research programmers, who probably don't have much
love left for something... bulbous... like C++. For business
programming, where managing a team of average, exchangable programmers
is paramount, the situation might be slightly different.
 
Reply With Quote
 
 
 
 
Grizlyk
Guest
Posts: n/a
 
      01-02-2009
On Dec 26 2008, 1:11*am, Lawand wrote:
>
> why does any programmer on earth still use/learn/
> teach C instead of C++?


But use or learn?

About learn.
People do not know strictly niether C no C++, and are not going to do
it, so people learn something mixed that looks more as subset of C++.
They learn the subset of C++ because of existing functional
(algorithmic) paradigm of programming - C, pascal and C++ support the
paradigm. People do not need C++ or C, they need only implementation
of the paradigm.

This is wrong idea, that anyone can learn object-oriented paradigm
without or befor funcional one.

About use.
What do you mean? People call functions, is it C? Or you are about
libraries? Again, anyone try to force others with concrete library?

Any good thing do no require any vague adverticement. If people select
C library, that means that profit from C++ libraries, that do the
same, does not visible. Probably C++ implementation worse, probably
there is no online help dictionary for their IDE to recollect
interfaces of C++ interfaces, probably something else.

> Shouldn't C++ have replaced C even when developing an OS kernel or
> such sensitive software?


C++ has some "elements of OO paradigm" only and must be redesigned to
support OO properties in effective manner. As alternative way, you can
use right now the considered above subset of C++ for functional
projets.
 
Reply With Quote
 
Greg Herlihy
Guest
Posts: n/a
 
      01-03-2009
On Dec 25 2008, 2:11 pm, Lawand <(E-Mail Removed)> wrote:
> Hello.
>
> AFAIKnew, people used to choose C over C++ as a programming language
> for their projects because it posses better performance and execution
> speed, but after I read this article <a herf="http://unthought.net/c++/
> c_vs_c++.htmle">(C versus C++)</a> I noticed that C++ beats C in
> benchmarking so, why does any programmer on earth still use/learn/
> teach C instead of C++?
>
> Shouldn't C++ have replaced C? even when developing an OS kernel or
> such sensitive software.


The entire premise of the question is, of course, completely false.
There is no such thing as a programmers who writes code in "C". There
do exist, however, a sizable number of C++ programmers who do decide -
for a variety of reasons (including inertia, smug self-righteousness
and -in most cases- simple mental illness) to use only a very limited
subset of the C++ programming language when they program. (For
example, many of these programmers will eschew C++ templates in favor
of preprocessor macros. And yes, despite the wildly implausibility of
this claim, this behavior has been documented in the field). In fact,
many of these afflicted programmers have become so delusional that
they no longer realize that they are programming in C++. Many believe
instead that they are programming in some other language (often, a
made-up programming language they call "C"). And, yes, there is ample
evidence to support this outlandish-sounding claim.

Of course the harm done by these programmers (who refuse to use the
full suite of C++ language) - is enormous. Think of all extra delays,
added bugs, and nightmarish maintenance scenarios that their refusal
directly cause.

Nevertheless, despite the clear incentive to fix this crisis, efforts
to reach this group of afflicted programmers and to provide them with
the help they need, have, by and large, proved unsuccessful. In many
cases, these programmers have had years to construct their defenses.
Often the programmer has entrenched themselves so thoroughly in the
software-writing process of their organization, that any thought of
extrication is simply not feasible..

Nevertheless, there are few small steps that we, as individual, right-
minded C++ programmers, can do to fight this huge problem. Here are a
few practices that every true C++ programmer should adopt immediately
in their day-to-day lives:

* Always correct any mention or reference to a "C" programming
language - immediately and forthrightly. Make it clear to your
audience that the correct term is: "the C++ programming language (or
some subset thereof)" Be sure to use the corrected phrase in its
entirety - do not abbreviate the correction in any way. Remember that
allowing any reference to a "C" programming language to go
unchallenged, only serves to feed the collective delusion.

* Whenever "C" code is discovered in a program, immediately rewrite
the infected program immediately and completely (using proper C++).
Leaving the malignant code as is, greatly increases the risk of
contagion.

* Train yourself to recognize the telltale signs of the C programming
psychosis in other programmers. For example, someone who uses /* */
instead of // to set off comments, or who religiously makes sure that
all declarations precede statements in the same scope, or who use an
overabundant number of preprocessor macros and #defines - is certainly
a peerson who warrants closer scrutiny. Remember, even noticing
something minor can nonetheless prove to be the decisive tip-off that
a fellow C++ programmer desperately needs your help. A note of
caution: once you have identified a sick C++ programmer, do not
confront the individual yourself. Instead, seek out the assistance of
a trained professional, competent in conducting the intervention (and
internment) that will be needed.

So. there you have it. The near term prognosis for ending this crisis
does remain bleak. Our best hope is that we each, on our own, fight
this problem locally, in our day-to-day lives. The hope is that - by
dint of our collective efforts - we will eventually turn the tide and
end this terrible scourge.

Greg

 
Reply With Quote
 
vib.cpp@gmail.com
Guest
Posts: n/a
 
      01-03-2009
On Dec 26 2008, 6:11*am, Lawand <(E-Mail Removed)> wrote:
> Hello.
>
> AFAIKnew, people used to choose C over C++ as a programming language
> for their projects because it posses better performance and execution
> speed, but after I read this article <a herf="http://unthought.net/c++/
> c_vs_c++.htmle">(C versus C++)</a> I noticed that C++ beats C in
> benchmarking so, why does any programmer on earth still use/learn/
> teach C instead of C++?
>
> Shouldn't C++ have replaced C? even when developing an OS kernel or
> such sensitive software.


i am now learning c++ for several months,with a book said i do not
have a pre-knowledge of c language,but when i know something about
cpp,a stronger feeling is that i must go and find some c language book
to solid my foundation now.I think some fundamental knowledge of
programming is easier to get familiar with from c ,
 
Reply With Quote
 
coal@mailvault.com
Guest
Posts: n/a
 
      01-04-2009
On Jan 2, 7:08*pm, Greg Herlihy <(E-Mail Removed)> wrote:
> On Dec 25 2008, 2:11 pm, Lawand <(E-Mail Removed)> wrote:
>
> > Hello.

>
> > AFAIKnew, people used to choose C over C++ as a programming language
> > for their projects because it posses better performance and execution
> > speed, but after I read this article <a herf="http://unthought.net/c++/
> > c_vs_c++.htmle">(C versus C++)</a> I noticed that C++ beats C in
> > benchmarking so, why does any programmer on earth still use/learn/
> > teach C instead of C++?

>
> > Shouldn't C++ have replaced C? even when developing an OS kernel or
> > such sensitive software.

>
> The entire premise of the question is, of course, completely false.
> There is no such thing as a programmers who writes code in "C". There
> do exist, however, a sizable number of C++ programmers who do decide -
> for a variety of reasons (including inertia, smug self-righteousness
> and -in most cases- simple mental illness) to use only a very limited
> subset of the C++ programming language when they program. (For
> example, many of these programmers will eschew C++ templates in favor
> of preprocessor macros. And yes, despite the wildly implausibility of
> this claim, this behavior has been documented in the field). In fact,
> many of these afflicted programmers have become so delusional that
> they no longer realize that they are programming in C++. Many believe
> instead that they are programming in some other language (often, a
> made-up programming language they call "C"). And, yes, there is ample
> evidence to support this outlandish-sounding claim.
>
> Of course the harm done by these programmers (who refuse to use the
> full suite of C++ language) - is enormous. Think of all extra delays,
> added bugs, and nightmarish maintenance scenarios that their refusal
> directly cause.
>
> Nevertheless, despite the clear incentive to fix this crisis, efforts
> to reach this group of afflicted programmers and to provide them with
> the help they need, have, by and large, proved unsuccessful. In many
> cases, these programmers have had years to construct their defenses.
> Often the programmer has entrenched themselves so thoroughly in the
> software-writing process of their organization, that any thought of
> extrication is simply not feasible..
>
> Nevertheless, there are few small steps that we, as individual, right-
> minded C++ programmers, can do to fight this huge problem. Here are a
> few practices that every true C++ programmer should adopt immediately
> in their day-to-day lives:
>
> * Always correct any mention or reference to a "C" programming
> language - immediately and forthrightly. Make it clear to your
> audience that the correct term is: "the C++ programming language (or
> some subset thereof)" Be sure to use the corrected phrase in its
> entirety - do not abbreviate the correction in any way. Remember that
> allowing any reference to a "C" programming language to go
> unchallenged, only serves to feed the collective delusion.
>
> * Whenever "C" code is discovered in a program, immediately rewrite
> the infected program immediately and completely (using proper C++).
> Leaving the malignant code as is, greatly increases the risk of
> contagion.
>


Previously I asked, "if not now, when?" regarding gcc/g++
development. http://preview.tinyurl.com/7qeokl

It would be great to hear of an effort to rework gcc as a C++
program. I think it would shed at least 30% of it's current
size if that were to happen. Unfortunately, people keep pasting
more on to large "C" programs and the programs turn into monsters.
I agree with the use of the word crisis here. We need to bite
the bullet and rewrite gcc.

Brian Wood
Ebenezer Enterprises
www.webEbenezer.net
 
Reply With Quote
 
pgadmin
Guest
Posts: n/a
 
      01-04-2009
In article <gjppgh$3qb$(E-Mail Removed)>, http://www.velocityreviews.com/forums/(E-Mail Removed)lid (pgadmin) wrote:
>In article <(E-Mail Removed)>,
> (E-Mail Removed) wrote:
>>On Jan 2, 7:08=A0pm, Greg Herlihy <(E-Mail Removed)> wrote:
>>> On Dec 25 2008, 2:11 pm, Lawand <(E-Mail Removed)> wrote:
>>>
>>> > Hello.
>>>
>>> > AFAIKnew, people used to choose C over C++ as a programming language
>>> > for their projects because it posses better performance and execution
>>> > speed, but after I read this article <a herf=3D"http://unthought.net/c+=

>>+/
>>> > c_vs_c++.htmle">(C versus C++)</a> I noticed that C++ beats C in
>>> > benchmarking so, why does any programmer on earth still use/learn/
>>> > teach C instead of C++?
>>>
>>> > Shouldn't C++ have replaced C? even when developing an OS kernel or
>>> > such sensitive software.
>>>
>>> The entire premise of the question is, of course, completely false.
>>> There is no such thing as a programmers who writes code in "C". There
>>> do exist, however, a sizable number of C++ programmers who do decide -
>>> for a variety of reasons (including inertia, smug self-righteousness
>>> and -in most cases- simple mental illness) to use only a very limited
>>> subset of the C++ programming language when they program. (For
>>> example, many of these programmers will eschew C++ templates in favor
>>> of preprocessor macros. And yes, despite the wildly implausibility of
>>> this claim, this behavior has been documented in the field). In fact,
>>> many of these afflicted programmers have become so delusional that
>>> they no longer realize that they are programming in C++. Many believe
>>> instead that they are programming in some other language (often, a
>>> made-up programming language they call "C"). And, yes, there is ample
>>> evidence to support this outlandish-sounding claim.

>
>I just remembered something about the 1st version of C++.
>Strousrup (sic) came to Cambridge, Mass. to implement the
>fist version of C++. There was no C++ then. We were working
>basically a couple of offices away, and once I asked him:
>
>Why C++ is implemented as preprocessor and not a compiler
>proper. He blabbered something that could not possibly
>make sense because basically there is not excuse to implement
>C++ as a preprocessor to C.


Btw, do you know how they made C++ objects?

Well, they patched the executable produced by C
after linking stage.

How do you like THAT fer breakfast?

:--}

>Well, very soon there was a C++ compiler proper.
>
>>> Of course the harm done by these programmers (who refuse to use the
>>> full suite of C++ language) - is enormous. Think of all extra delays,
>>> added bugs, and nightmarish maintenance scenarios that their refusal
>>> directly cause.

>
>But what if you write device driver or kernel code?
>The entire Linux kernel, the last time I looked at the sources,
>is written in C.
>
>At the kernel level, there is a difference between C and C++.
>
>And that difference is performance. At the kernel level,
>each indirection is a memory reference, which is much slower
>than register access.
>
>The penalty in performance is probably around 50%, AT LEAST,
>compared to pure C.
>
>C++ is a toy kind of thing. Yes, it does help a lot on
>application level where you can afford the performance
>losses. Sure, your more abstract view of computation
>reduces to cleaner, more structured programs, but what is
>C++ class object to begin with?
>
>Well, it is a C structure. Nothing more.
>So...
>
>>> Nevertheless, despite the clear incentive to fix this crisis, efforts
>>> to reach this group of afflicted programmers

>
>What "crisis"?
>What "afflicted" programmers?
>
>Why do you need to make them look sick?
>
>Do you have a slightest idea of what they are doing?
>
>I tell you one thing, if you come to certain departments,
>where the CORE issues are resolved, and pump your chest
>as C++, holier than though, programmer, they're just gonna
>laugh at you and quickly move away.
>
>Because your talk is simply infantile.
>
>What are you trying to concoct here?
>
>Enough for now.
>
>>> and to provide them with
>>> the help they need, have, by and large, proved unsuccessful. In many
>>> cases, these programmers have had years to construct their defenses.
>>> Often the programmer has entrenched themselves so thoroughly in the
>>> software-writing process of their organization, that any thought of
>>> extrication is simply not feasible..
>>>
>>> Nevertheless, there are few small steps that we, as individual, right-
>>> minded C++ programmers, can do to fight this huge problem. Here are a
>>> few practices that every true C++ programmer should adopt immediately
>>> in their day-to-day lives:
>>>
>>> * Always correct any mention or reference to a "C" programming
>>> language - immediately and forthrightly. Make it clear to your
>>> audience that the correct term is: "the C++ programming language (or
>>> some subset thereof)" Be sure to use the corrected phrase in its
>>> entirety - do not abbreviate the correction in any way. Remember that
>>> allowing any reference to a "C" programming language to go
>>> unchallenged, only serves to feed the collective delusion.
>>>
>>> * Whenever "C" code is discovered in a program, immediately rewrite
>>> the infected program immediately and completely (using proper C++).
>>> Leaving the malignant code as is, greatly increases the risk of
>>> contagion.
>>>

>>
>>Previously I asked, "if not now, when?" regarding gcc/g++
>>development. http://preview.tinyurl.com/7qeokl
>>
>>It would be great to hear of an effort to rework gcc as a C++
>>program. I think it would shed at least 30% of it's current
>>size if that were to happen. Unfortunately, people keep pasting
>>more on to large "C" programs and the programs turn into monsters.
>>I agree with the use of the word crisis here. We need to bite
>>the bullet and rewrite gcc.
>>
>>Brian Wood
>>Ebenezer Enterprises
>>www.webEbenezer.net

 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      01-04-2009
On Jan 4, 8:46 am, (E-Mail Removed) (pgadmin) wrote:
> In article
> <(E-Mail Removed)>,
> (E-Mail Removed) wrote:


> >On Jan 2, 7:08=A0pm, Greg Herlihy <(E-Mail Removed)> wrote:
> >> On Dec 25 2008, 2:11 pm, Lawand <(E-Mail Removed)> wrote:


> >> > AFAIKnew, people used to choose C over C++ as a
> >> > programming language for their projects because it posses
> >> > better performance and execution speed, but after I read
> >> > this article <a herf=3D"http://unthought.net/c++/
> >> > c_vs_c++.htmle">(C versus C++)</a> I noticed that C++
> >> > beats C in benchmarking so, why does any programmer on
> >> > earth still use/learn/ teach C instead of C++?


> >> > Shouldn't C++ have replaced C? even when developing an OS
> >> > kernel or such sensitive software.


> >> The entire premise of the question is, of course,
> >> completely false. There is no such thing as a programmers
> >> who writes code in "C". There do exist, however, a sizable
> >> number of C++ programmers who do decide - for a variety of
> >> reasons (including inertia, smug self-righteousness and -in
> >> most cases- simple mental illness) to use only a very
> >> limited subset of the C++ programming language when they
> >> program. (For example, many of these programmers will
> >> eschew C++ templates in favor of preprocessor macros. And
> >> yes, despite the wildly implausibility of this claim, this
> >> behavior has been documented in the field). In fact, many
> >> of these afflicted programmers have become so delusional
> >> that they no longer realize that they are programming in
> >> C++. Many believe instead that they are programming in some
> >> other language (often, a made-up programming language they
> >> call "C"). And, yes, there is ample evidence to support
> >> this outlandish-sounding claim.


This is, of course, false. There is still a C language, there
are C compilers, and some people are still using them.

> I just remembered something about the 1st version of C++.
> Strousrup (sic) came to Cambridge, Mass. to implement the fist
> version of C++. There was no C++ then. We were working
> basically a couple of offices away, and once I asked him:


> Why C++ is implemented as preprocessor and not a compiler
> proper. He blabbered something that could not possibly make
> sense because basically there is not excuse to implement C++
> as a preprocessor to C.


> Well, very soon there was a C++ compiler proper.


Except that C++ was invented by a guy named Stroustrup, not
Strousrup, at Bell labs in New Jersey. (I don't think
Stroustrup ever worked or studied at Cambridge, Mass. His PhD is
from Cambridge University, in Cambridge, UK.)

And of course, C++ was never a "preprocessor" for C. Like many
languages, the early (and some not so early) compilers used C as
an intermedite, machine independent, intermediate language,
between the front-end and the back-end.

> >> Of course the harm done by these programmers (who refuse to
> >> use the full suite of C++ language) - is enormous. Think of
> >> all extra delays, added bugs, and nightmarish maintenance
> >> scenarios that their refusal directly cause.


> But what if you write device driver or kernel code?
> The entire Linux kernel, the last time I looked at the sources,
> is written in C.


That probably explains why it is so unreliable. (Or at least
why it took so long to acquire even a semblance of reliability.)

> At the kernel level, there is a difference between C and C++.


At all levels, there's a difference. They're two different
languages.

> And that difference is performance. At the kernel level, each
> indirection is a memory reference, which is much slower than
> register access.


> The penalty in performance is probably around 50%, AT LEAST,
> compared to pure C.


That's bullshit, of course. All of the compilers I've seen
generate exactly the same code for C and for C++. (Potentially,
C++ could be faster, because it provides more information to the
compiler. For various reasons, however, this isn't the case,
and I don't really expect it to ever be the case.)

Modern OS's are written in C++. Modern OS's are rare, though;
most OS's have been around for a long time, and have just grown.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
s0suk3@gmail.com
Guest
Posts: n/a
 
      01-04-2009
On Jan 4, 1:46*am, (E-Mail Removed) (pgadmin) wrote:
> At the kernel level, there is a difference between C and C++.


Although I'm not familiar with kernel development, I do have heard
about a few such differences (e.g., things having to do with the ABI).
However, what you point out:

> And that difference is performance.


is NOT one of the differences. Every feature of C++ that is also
available in C has the same behavior and semantics in C++ as it does
in C.

Although there might be some variations in the resulting machine code
when C/C++ code is compiled in C mode and when it's compiled in C++
mode, the performance doesn't usually vary. For example, name mangling
is usually done differently for C++ code than for C code. Of course,
the resulting mangled names have nothing to with code speed.

(Read James Kanze's post to hear why C++ mode could in fact yield
faster code.)

> At the kernel level,
> each indirection is a memory reference, which is much slower
> than register access.


You can reference a memory location and access a register in both C
and C++, in the same ways.

> The penalty in performance is probably around 50%, AT LEAST,
> compared to pure C.


Unsupported claim. Repeat after me: Every feature of C++ that is also
available in C has the same behavior and semantics in C++ as it does
in C.

Sebastian

 
Reply With Quote
 
Grizlyk
Guest
Posts: n/a
 
      01-05-2009
> On Jan 4, 10:46*am, pgadmin wrote:
>
> At the kernel level, there is a difference between C and C++.


For example, protability. But, in order to speak about language we
must select level of discussion
- standard C++,
- real compilers and environment
- etc.

If you take "ordinary C++ environment" and "ordinary C environment",
that you will easy find profits for "pure C" for the kind of programs.
But if you will speak about "what C++ could do", then "C++" would be
better.

> And that difference is performance. At the kernel level,
> each indirection is a memory reference, which is much slower
> than register access.


Yes, C++ allows users to write code with bad performance. For example,
well known string operation. Some users copy strings by value in free
manner and easy lose performance. You must use abstractions of C++
with care.

As i have said, now the best way to use C++ is some ADT+templates
+patterns under C-stile design. You will get profits without lost of
any performance.

===
grizlyk
 
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
Do people still use a shutter release cable in digital camera age? aniramca@gmail.com Digital Photography 30 07-24-2007 04:55 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why are people still using classic classes? Simon Wittber Python 16 01-14-2005 09:53 PM
Why do people still insist that the holocaust didn't occur? Fred A. Miller Digital Photography 11 02-26-2004 12:49 AM
STL: Do people still use char[] buffers? syncman C++ 4 01-20-2004 09:09 PM



Advertisments