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

Discussion in 'C++' started by Lawand, Dec 25, 2008.

  1. Lawand

    Lawand Guest

    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.
    Lawand, Dec 25, 2008
    #1
    1. Advertising

  2. Lawand

    Ian Collins Guest

    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
    Ian Collins, Dec 25, 2008
    #2
    1. Advertising

  3. Lawand

    Rolf Magnus Guest

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


    Not sure about PIC, but there is one for AVR.
    Rolf Magnus, Dec 26, 2008
    #3
  4. Lawand

    Guest

    On 26 joulu, 00:11, Lawand <> wrote:
    > benchmarking so, why does any programmer on earth still use/learn/
    > teach C instead of C++?


    For many reasons. Usually people have irrational reasons for
    using thing X. That's how people are. Even I was like that and
    I'm a genius.
    , Dec 26, 2008
    #4
  5. Lawand

    Lawand Guest

    On Dec 26, 1:40 am, Ian Collins <> 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++ ?
    Lawand, Dec 26, 2008
    #5
  6. Lawand

    maverik Guest

    On Dec 26, 1:11 am, 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.


    Probably, it's better to use a tool that is better suited to your
    task. So it depends.

    For example, you want to eat a plate of soup. You have 2 ways: you can
    use a spoon or an excavator shovel. It is well known that shovel more
    powerful tool for rake and beats the spoon. So, should you use
    excavator shovel? Probably not. And why? Because, a spoon can solve
    this problem more efficiently that the excavator shovel.
    maverik, Dec 26, 2008
    #6
  7. Lawand

    Guest

    On Dec 25, 5:11 pm, 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++?


    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
    , Dec 26, 2008
    #7
  8. Lawand

    Guest

    On Dec 26, 11:37 am, (blargg) wrote:
    > maverik wrote:
    > > On Dec 26, 1:11=A0am, 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=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.

    >
    > > Probably, it's better to use a tool that is better suited to your
    > > task. So it depends.

    >
    > > For example, you want to eat a plate of soup. You have 2 ways: you can
    > > use a spoon or an excavator shovel. It is well known that shovel more
    > > powerful tool for rake and beats the spoon. So, should you use
    > > excavator shovel? Probably not. And why? Because, a spoon can solve
    > > this problem more efficiently that the excavator shovel.

    >
    > But let's say you regularly eat a plate of soup at a place where, for some
    > odd reason, they don't provide utensils. You also sometimes do shoveling
    > when you're out. You'd bring a spoon and the excavator shovel, and use the
    > spoon for the soup. C++ gives you both, and you don't have to use anything
    > more than the spoon when metaphorically eating soup. You always have the
    > option of using a more fancy spoon, also part of C++, building your own
    > spoon, or (mis)using the shovel. The choice is yours. So why would C++ be
    > ill-suited in a situation where C is suited?


    This is a really silly analogy that shouldn't have been made in the
    first place. Not quite sure why programmers are so keen on ridiculous
    analogies all the time. It's not even necessary, and doesn't make all
    that much sense. "C++ gives you both a spoon AND a shovel but C only
    gives you a spoon OR a shovel" isn't really a compelling statement
    of... anything at all. Sorry.

    Mentioning the word "efficient", in the context of performance, is
    also irrelevant. The languages are the same and the article does not
    actually attempt to show a "performance" difference between the two
    (go read it).

    The article does explain that C is more verbose for certain tasks. The
    compiled code is not going to differ that much between the two. You
    can express the same programs with both, you just have to type more
    with C sometimes.

    HTH,
    Jason
    , Dec 26, 2008
    #8
  9. Lawand

    Lawand Guest

    On Dec 26, 6:43 pm, ""
    <> wrote:
    > On Dec 25, 5:11 pm, 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++?

    >
    > 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?
    Lawand, Dec 26, 2008
    #9
  10. Lawand

    Rui Maciel Guest

    Lawand wrote:

    > Calm down :)


    Trolls don't usually make people get calmer.


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


    You are putting words into jason's mouth. You failed to read the article and jason pointed out that even the article clearly stated that their benchmarks could not be used to compare the languages in those silly and pointless "language A Vs language B" discussions, which was what you promptly did.

    Moreover, C and C++ are two different languages that scratch different itches. The only person that keeps forcing the "language A is better than language B" conclusion is, well... you.


    Rui Maciel
    Rui Maciel, Dec 26, 2008
    #10
  11. On 26 déc, 18:23, Lawand <> wrote:
    > On Dec 26, 6:43 pm, ""
    >
    >
    >
    > <> wrote:
    > > On Dec 25, 5:11 pm, 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++?

    >
    > > 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.
    Laurent Deniau, Dec 26, 2008
    #11
  12. Lawand

    Bo Persson Guest

    Lawand wrote:
    > On Dec 26, 1:40 am, Ian Collins <> 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
    Bo Persson, Dec 26, 2008
    #12
  13. Lawand

    Bo Persson Guest

    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
    Bo Persson, Dec 26, 2008
    #13
  14. Lawand

    Guest

    On Dec 26, 12:23 pm, Lawand <> wrote:
    > On Dec 26, 6:43 pm, ""
    >
    >
    >
    > <> wrote:
    > > On Dec 25, 5:11 pm, 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++?

    >
    > > 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
    , Dec 27, 2008
    #14
  15. Lawand

    Guest

    On Dec 25, 5:11 pm, Lawand <> 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.
    , Dec 27, 2008
    #15
  16. Lawand

    James Kanze Guest

    On Dec 26, 2:19 pm, Lawand <> wrote:
    > On Dec 26, 1:40 am, Ian Collins <> 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
    James Kanze, Dec 27, 2008
    #16
  17. Lawand

    Rolf Magnus Guest

    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).
    Rolf Magnus, Dec 27, 2008
    #17
  18. On 27 déc, 00:32, "Bo Persson" <> 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.
    Laurent Deniau, Dec 27, 2008
    #18
  19. On 27 déc, 20:24, Rolf Magnus <> 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.
    Laurent Deniau, Dec 27, 2008
    #19
  20. Lawand

    Guest

    On Dec 27, 6:58 pm, Laurent Deniau <> wrote:
    > On 27 déc, 20:24, Rolf Magnus <> 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.
    , Dec 28, 2008
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. syncman
    Replies:
    4
    Views:
    1,742
    Rob Williscroft
    Jan 20, 2004
  2. Simon Wittber
    Replies:
    16
    Views:
    565
    Steve Holden
    Jan 14, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,736
    Smokey Grindel
    Dec 2, 2006
  4. Kenneth McDonald

    People still using Tkinter?

    Kenneth McDonald, May 10, 2008, in forum: Python
    Replies:
    11
    Views:
    546
    Kevin Walzer
    May 10, 2008
  5. Replies:
    1
    Views:
    692
    Roger Lindsjö
    Jun 11, 2008
Loading...

Share This Page