Is c++ a better c?

This is a discussion on Is c++ a better c? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; hi, Could someone ans this for me its bugging me for a long time. Is c++ a better c? If ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    3

    Is c++ a better c?

    hi,
    Could someone ans this for me its bugging me for a long time.

    Is c++ a better c? If so why is c still being used? Tell me some uses as well.

    please help.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    In one sentence:

    C++ adds some nice features, at the cost of some performance.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    That's all a matter of opinion. In my opinion, it's an "of course it is." However, you will find some people who will disagree.

    Why?

    C++ is basically C but with a whole bunch extra. Just about anything you can do in C++ as well, even using the same syntax (in most cases), however C++ offers better type checking and an incredible amount of more built-in functionality.

    One of the reasons C is still used a lot is because it's a hell-of-alot easier to make a C compiler than it is to make a C++ compiler. All of it's functionality is fairly low-level (for a high-level language).

    C++, on the other hand, has a LOT more than that. On top of all that C has, it introduces of an entire new paradigm of programming. There is so much to the language of C++ that it's a lot more difficult and takes much more time to create a compiler for it than for C, and even still, there are very few compilers that can claim nearly 100% compliance to the C++ standard.

    In short, most of the people who think think C++ isn't a better C think so because they feel that a simpler language is an easier to understand language is a better language (which actually ends up being quite the opposite on large-scale applications). It all comes down to opinion, though I feel very strongy, yes, c++ is definately a "better c" (and much much more than that).

  4. #4
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Magos
    C++ adds some nice features, at the cost of some performance.
    I'd have to disagree with that to some extent. You can use the "C features" of C++ and get the same or better performance than of C (depending on the compiler). And when it comes to using member functions, it's potentially just as fast as passing the address of a structure in C. When it comes to virtual functions, you have to take into account the fact that in order to get similar functionality you'd have to either make your OWN vtable (which would give you most-likely the same, or less speed), or you'd have to set up enumerated values, etc.

    In actuality, c++'s "C features" are potentially just as fast and there's no reason they can't be faster. It's impossible to compare the higher level features of C++ to C because there is no direct correspondence between functionality, however, if you tried to simulate the functionality in C manually, your results would most-likely be slower than that of a C++ compiler.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    24
    I started with C++ but after a while I changed to C because it is easier to understand and you can do all the same things like with C++(with C it take longer to write the same program, but the code is also easier to understand then the C++ code with classes and the other things)

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by PawelK
    I started with C++ but after a while I changed to C because it is easier to understand and you can do all the same things like with C++(with C it take longer to write the same program, but the code is also easier to understand then the C++ code with classes and the other things)
    I don't know wich tutorial you've taken, But C++ can accept
    C code, So you can just program C++ without classes and such
    you don't understand.

  7. #7
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>Is c++ a better c?
    In my opinion, big yes.

    >>If so why is c still being used?
    If there are so many better languages out there, why is FORTRAN still being used? :-)
    *Cela*

  8. #8
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > So you can just program C++ without classes and such
    you don't understand.

    Then you've thrown away the biggest bonus for using C++ in the first place.

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Govtcheez
    > So you can just program C++ without classes and such
    you don't understand.

    Then you've thrown away the biggest bonus for using C++ in the first place.
    I know, But he said he wen't programming C while he just
    could've stuck with C++ and just don't use C++ features he
    doesnt understand, I dont get it.

  10. #10
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Govtcheez
    > So you can just program C++ without classes and such
    you don't understand.

    Then you've thrown away the biggest bonus for using C++ in the first place.
    And you are left still with C++'s

    Better type-checking
    Templating
    More expansive standard library (if you're okay with USING objects and just not creating classes)
    Upgraded ?: operator
    And a bunch more!

    Sure classes are [arguably] the biggest bonus (some might say templating is), but there are still other reasons one would use c++.

  11. #11
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >Is c++ a better c? If so why is c still being used? Tell me some uses as well.

    I don't think one of the two is best. C is still used a lot, for example in embedded systems development.

  12. #12
    Terrance11
    Guest

    Re: Is c++ a better c?

    Originally posted by dark


    Is c++ a better c?.
    Yes, of course, it's a superset of c (mostly a superset for those of you who might jump on me for not adding that). OOP and STL is what's going to allow programmers progress in the future while the size of programs continuously grows.

    Originally posted by dark
    If so why is c still being used? Tell me some uses as well.
    C++ is (in a lot regards) a different language. Old time C'ers may stick with what they like, rather than using C++.

    100% pure c may still be using in embedded systems programming, or in other instances that speed is a factor, but even c++ has taken over a considerable amount in those areas.

    Another reason C is still being used is legacy code. C'er's will always be needed in that sense.

    But as programs get more complex (and they always will), c will continue to be used less and less.

    Since most application in c/c++ are windows programs, I can't see many coding in windows api for large scale projects for the future, which would force many c'ers to start moving into C++/MFC.

    And I don't even want to get into the business aspects of why c++ would be used over c, but as you can all tell, I'm a c++'er

    But those are just my opinions, I know I've been shot down for promoting c++ before, but I feel I'm correct.

    Sorry, but I'm anti- C. (not C++!)

  13. #13
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    dark, when you ask that type of questions, you should always keep in mind that what might seem better to you, might be worse to some one else.
    I think you should've asked, what is the difference between C and C++? And that question have been answered many times.
    none...

  14. #14
    Registered User
    Join Date
    Feb 2003
    Posts
    3

    Smile

    Originally posted by ammar
    I think you should've asked, what is the difference between C and C++?
    ammar i didn't want to know the difference between C and C++.
    i think i did ask the right question and got the answers i needed. thankx for suggesting.


    thankx everyone especially Terrance11(got a lot of info from you).

  15. #15
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    BTW: I think if you are asking to determine what language you are going to learn, you can simply learn both of them, because it's not difficult to learn one when you already know the other.
    none...

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21