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-26-2008
On 26 déc, 18:23, Lawand <lawan...@gmail.com> wrote:
> On Dec 26, 6:43*pm, "jason.cipri...@gmail.com"
>
>
>
> <jason.cipri...@gmail.com> wrote:
> > On Dec 25, 5:11*pm, Lawand <lawan...@gmail.com> 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++?

>
> > You must not have read the article, or you're here trolling. It was an
> > RB-tree implemented in C++ vs. a hash table implemented in C. At the
> > bottom of the article, it clearly states:

>
> > "But this benchmark is no good for the purpose of the "C versus C++"
> > argument - it's two completely different approaches that yield
> > completely different results, for reasons that have nothing to do with
> > the languages used."

>
> > There's not, actually, a difference in performance between the two.
> > They're both compiled to native code, frequently by a compiler that
> > handles both languages at once, using the same logic for compilation.
> > Check out the code your compiler generates. A performance difference
> > between the two languages wouldn't actually make any sense. Any byte
> > code you produce from C++ can be produced almost identically with C,
> > except it will take you a heck of a lot longer to express it in C. The
> > only big difference in "performance" is your algorithms, as shown in
> > the article.

>
> > I guess you missed that part?

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

>
> > You're welcome to port the existing Linux kernel (for example), to C+
> > +. While you're working on it, you can reflect on why nobody else has
> > done it yet.

>
> > Most of the time the reasons are that you are maintaining code written
> > in C or you are on a platform that nobody has bothered to write a C++
> > compiler for (e.g. PIC). A lot of programmers raised on C will stick
> > to C because it's what they know, with logic like "well if you're not
> > going to use the features of C++, you might as well use C". An
> > experienced C programmer has techniques that he's comfortable with and
> > simply doesn't see a need to switch. I guess that's reasonable, who
> > knows (or cares)?

>
> > C++ also took a bit of time to become accepted because early (e.g. mid
> > 90's) compilers were strange and quirky. This also probably left a bad
> > taste in the mouth of those who attempted to learn it at the time.
> > Most C++ compilers are mature enough now that it's no longer an issue.

>
> > HTH, and next time read the article.
> > Jason

>
> Calm down
>
> 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 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++. 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.

a+, ld.
 
Reply With Quote
 
 
 
 
Bo Persson
Guest
Posts: n/a
 
      12-26-2008
Lawand wrote:
> On Dec 26, 1:40 am, Ian Collins <ian-n...@hotmail.com> wrote:
>> Lawand 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.

>>
>> Have you ever tried to find a C++ compiler for a PIC?
>>
>> --
>> Ian Collins

>
> That's something I haven't thought of, but let's say there isn't, in
> that case, is the lack of C++ compilers for micro controllers means
> that there can't be, or means that there shouldn't be.
> Or maybe they didn't design one because it's complex.
>
> Anyway, it's not what I am wondering about, what I don't know the
> reason of, is writing code (for CPUs, not micro controllers) such as
> OS kernels in C instead of C++.
> I mean, why bother using C where there exist a more programmer
> efficient and faster counterpart, the C++ ?


There are OS kernels written in C++, like Symbian, so it is very
possible.

The main reason for the major operating systems is that they have been
around since before C++ became a viable option. They were started out
in C, and has kept this tradition.


Bo Persson


 
Reply With Quote
 
 
 
 
Bo Persson
Guest
Posts: n/a
 
      12-26-2008
Laurent Deniau wrote:
>
> C++ is not a super set of C 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++.



I am really curious here - wanna give some examples?


Bo Persson


 
Reply With Quote
 
jason.cipriani@gmail.com
Guest
Posts: n/a
 
      12-27-2008
On Dec 26, 12:23*pm, Lawand <lawan...@gmail.com> wrote:
> On Dec 26, 6:43*pm, "jason.cipri...@gmail.com"
>
>
>
> <jason.cipri...@gmail.com> wrote:
> > On Dec 25, 5:11*pm, Lawand <lawan...@gmail.com> 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++?

>
> > You must not have read the article, or you're here trolling. It was an
> > RB-tree implemented in C++ vs. a hash table implemented in C. At the
> > bottom of the article, it clearly states:

>
> > "But this benchmark is no good for the purpose of the "C versus C++"
> > argument - it's two completely different approaches that yield
> > completely different results, for reasons that have nothing to do with
> > the languages used."

>
> > There's not, actually, a difference in performance between the two.
> > They're both compiled to native code, frequently by a compiler that
> > handles both languages at once, using the same logic for compilation.
> > Check out the code your compiler generates. A performance difference
> > between the two languages wouldn't actually make any sense. Any byte
> > code you produce from C++ can be produced almost identically with C,
> > except it will take you a heck of a lot longer to express it in C. The
> > only big difference in "performance" is your algorithms, as shown in
> > the article.

>
> > I guess you missed that part?

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

>
> > You're welcome to port the existing Linux kernel (for example), to C+
> > +. While you're working on it, you can reflect on why nobody else has
> > done it yet.

>
> > Most of the time the reasons are that you are maintaining code written
> > in C or you are on a platform that nobody has bothered to write a C++
> > compiler for (e.g. PIC). A lot of programmers raised on C will stick
> > to C because it's what they know, with logic like "well if you're not
> > going to use the features of C++, you might as well use C". An
> > experienced C programmer has techniques that he's comfortable with and
> > simply doesn't see a need to switch. I guess that's reasonable, who
> > knows (or cares)?

>
> > C++ also took a bit of time to become accepted because early (e.g. mid
> > 90's) compilers were strange and quirky. This also probably left a bad
> > taste in the mouth of those who attempted to learn it at the time.
> > Most C++ compilers are mature enough now that it's no longer an issue.

>
> > HTH, and next time read the article.
> > Jason

>
> 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?


No.

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


No.

It seems you read my post about as closely as you read that article.
Jason
 
Reply With Quote
 
perlwhiz@yahoo.com
Guest
Posts: n/a
 
      12-27-2008
On Dec 25, 5:11*pm, Lawand <lawan...@gmail.com> wrote:
>
> Shouldn't C++ have replaced C? even when developing an OS kernel or
> such sensitive software.


I'm reminded of Linus Torvalds' big rant against C++ last year. Google
"linus torvalds c++" and read his posts at gmane.org for another
opinion.
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      12-27-2008
On Dec 26, 2:19 pm, Lawand <lawan...@gmail.com> wrote:
> On Dec 26, 1:40 am, Ian Collins <ian-n...@hotmail.com> 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="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.


> > Have you ever tried to find a C++ compiler for a PIC?


> That's something I haven't thought of, but let's say there
> isn't, in that case, is the lack of C++ compilers for micro
> controllers means that there can't be, or means that there
> shouldn't be. Or maybe they didn't design one because it's
> complex.


Or because their competitors didn't, so they don't feel the need
to.

> Anyway, it's not what I am wondering about, what I don't know
> the reason of, is writing code (for CPUs, not micro
> controllers) such as OS kernels in C instead of C++.


Most OS kernels for modern general purpose machines do contain
quite a bit of C++. Significant parts of the many of the
kernels, however, were written before C++ was generally
available.

> I mean, why bother using C where there exist a more programmer
> efficient and faster counterpart, the C++ ?


Mainly habit and existing code.

--
James Kanze (GABI Software) email:
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
 
Rolf Magnus
Guest
Posts: n/a
 
      12-27-2008
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 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).
 
Reply With Quote
 
Laurent Deniau
Guest
Posts: n/a
 
      12-27-2008
On 27 déc, 00:32, "Bo Persson" <b...@gmb.dk> wrote:
> Laurent Deniau wrote:
>
> > C++ is not a super set of C 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++.

>
> I am really curious here *- wanna give some examples?


google for "C Object System" or go to sourceforge. COS itself cannot
be implemented in C++ AFAIK and it would be very complex to implement
even by a C++ compiler ("The good is the enemy of the best"). It
provides the dynamic counterpart of the template, that is multi-
methods which I consider to be more important than templates.
Obviously, if I could have both, it would be even better. Another
feature that I consider very important is the (generic) delegation and
it can only be implemented on top of messages.

a+, ld.
 
Reply With Quote
 
Laurent Deniau
Guest
Posts: n/a
 
      12-27-2008
On 27 déc, 20:24, Rolf Magnus <ramag...@t-online.de> 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 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.

a+, ld.
 
Reply With Quote
 
jason.cipriani@gmail.com
Guest
Posts: n/a
 
      12-28-2008
On Dec 27, 6:58*pm, Laurent Deniau <Laurent.Den...@gmail.com> wrote:
> On 27 déc, 20:24, Rolf Magnus <ramag...@t-online.de> 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.

2. The COS Makefiles do not build. It appears you used something like
autoconf but did not actually include a configure script in CVS. 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.

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.


> > > 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? Issues with... type checking or something? 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++".

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. 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++...

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


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. 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.
 
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? beefshank@kebi.com Digital Photography 12 02-26-2004 12:49 AM
STL: Do people still use char[] buffers? syncman C++ 4 01-20-2004 09:09 PM



Advertisments