Like Tree32Likes

C++ vs C

This is a discussion on C++ vs C within the General Discussions forums, part of the Community Boards category; Actually, Brewbuck's original statement was that C++ is superior to C. This argument can, in theory (and most likely in ...

  1. #31
    Registered User
    Join Date
    Jun 2011
    Posts
    2,061
    Actually, Brewbuck's original statement was that C++ is superior to C. This argument can, in theory (and most likely in practice), be qualitatively demonstrated. However, I don't think this necessarily translates to C++ being "better" than C - because "better" is a more subjective quality and not easily demonstrable.

    Also, I'm not disagreeing with the OP (nor am I agreeing), but I find it surprising that those who do agree have yet to provide the criteria they are using to support their positions (other than, "At the very least, C++ can do what C does").

    Personally, I'm here to participate in a discussion and learn, not defend a particular point of view. Describing what one thinks is not nearly as informative as to why they think it.

  2. #32
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,490
    Wow...we're still having this debate in 2012!
    So...instead of adding the standard "language is a tool" which others have already put forward......
    Name:  ctoc.jpg
Views: 91
Size:  7.5 KB
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #33
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489
    My sig. 'nuff said.
    Elkvis likes this.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  4. #34
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    3,798
    I find it surprising that those who do agree have yet to provide the criteria they are using to support their positions
    Your problem is that you haven't bothered to understand the criteria that is always posted when this notion is posted.

    C++ gives you access to some features that C simply doesn't have and some features that can't be reasonably emulated. C++ offers such features but does not force such features upon programmers.

    C++ offers "OOP" mechanisms like polymorphisms "out of the box". C++ doesn't force a programmer to use a `class' to package data. The programmer, and not the language, makes design decisions that best fit the problem at hand.

    C++ gives me, the programmer, access to a lot of tools and mostly stays the ........ out of my way while I use them. That simple bit of absolute fact makes it superior to C and most other languages.

    The language forcing me into crap, like packaging everything into a "class" or "feature", is completely retarded.

    I mean that extremely literally; languages the get in my way by forcing me into crap hold me and my productivity back.

    C++ is a superior language to C. That doesn't, in any way, suggest that C++ is always the right tool for the job.

    I find it surprising that so many programmers don't understand simple truths when confronted with them.

    In any case, I'm here to tell everyone that C# is a better Java.
    O_o

    Well, it isn't as if that was a difficult thing to manage.

    Soma

  5. #35
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    934
    Well, there is atleast one way that C beats C++: Complexity. A fully compliant C++0x compiler is tremendously complicated, while a C compiler is far simpler. Therefore it is not infeasible to imagine a platform where there simply isn't a C++ compiler available, yet a C-compiler could very well be.

    I imagine the immense complexity of the language also affects compile-time, although i have nothing to substantiate this claim.

    I think complexity could very well become a problem if the standard keeps expanding.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  6. #36
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,490
    Quote Originally Posted by Neo1 View Post
    Well, there is atleast one way that C beats C++: Complexity. A fully compliant C++0x compiler is tremendously complicated, while a C compiler is far simpler. Therefore it is not infeasible to imagine a platform where there simply isn't a C++ compiler available, yet a C-compiler could very well be.

    I imagine the immense complexity of the language also affects compile-time, although i have nothing to substantiate this claim.

    I think complexity could very well become a problem if the standard keeps expanding.
    On the other side of your complexity coin...
    C++ being a complex language often results in *much* simpler code, which I think is more important for a programmer.
    Just try making something like std::vector in C....you are guaranteed to throw up (a mixture of void* s and macros )!
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  7. #37
    Registered User
    Join Date
    Jun 2011
    Posts
    2,061
    Your problem is that you haven't bothered to understand the criteria that is always posted when this notion is posted.
    This is my first time participating in such a discussion here. I just figure if it's going to be discussed again, arguments should be supported by claims - which you have provided here

    I find it surprising that so many programmers don't understand simple truths when confronted with them.
    If you're lumping me into that category - it's not a matter of "not understanding simple truths," but simply a matter of desiring more information on a claim put forth.

  8. #38
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    Quote Originally Posted by Matticus View Post
    If you're lumping me into that category - it's not a matter of "not understanding simple truths," but simply a matter of desiring more information on a claim put forth.
    I find it very unlikely that anything that has been said is news to you.

    We didn't get Linus Torvaldus in here. So let's not complicate it more than it should.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #39
    Registered User
    Join Date
    Jun 2011
    Posts
    2,061
    Quote Originally Posted by Mario F. View Post
    I find it very unlikely that anything that has been said is news to you.
    Apart from a three week C++ stint several years back, I have precious little knowledge of the language. I understand some of the basics, but that's about it. It's not so much a question of syntax and keywords, but more about what the language has to offer as a whole - it's outside of my experience. My request for more insight was in order for me to better understand the arguments presented here, as well as learning in general. As I understand it, these forums are supposed to be largely educational.

  10. #40
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    934
    Quote Originally Posted by manasij7479 View Post
    On the other side of your complexity coin...
    C++ being a complex language often results in *much* simpler code, which I think is more important for a programmer.
    Just try making something like std::vector in C....you are guaranteed to throw up (a mixture of void* s and macros )!
    Certainly we get something in return for the added complexity, that was never my point.

    My point was that there is also a cost to all this complexity. One of them being complex compilers (and therefore fewer and slower compilers).
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  11. #41
    Registered User
    Join Date
    Oct 2006
    Posts
    2,142
    Quote Originally Posted by Neo1 View Post
    ...fewer and slower compilers
    I would counter this with the fact that a "simpler" language necessarily requires more complex code. the time you save compiling is much more than offset by the time it takes to write the code.

  12. #42
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    934
    Quote Originally Posted by Elkvis View Post
    I would counter this with the fact that a "simpler" language necessarily requires more complex code. the time you save compiling is much more than offset by the time it takes to write the code.
    Unless you're writing a C++ compiler :-)

    Seriously though, imo we're not there yet, but if the standard keeps expanding, at some point it's going to stop being new exciting features, and start becoming bloat. Some people might argue that we're already at that point.
    Seabass likes this.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  13. #43
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,303
    Why do so many places say that mixing C code in C++ code is dangerous?

    I don't know a lot about C++, but this seems to continuously be mentioned when researching this topic.
    Fact - Beethoven wrote his first symphony in C

  14. #44
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    There are two sides of the coin to ponder here, really.

    The first is the languages themselves. The languages, and nothing else. No compilers, no ecosystem, no support tools, not guidelines, etc, etc. Just the languages, the productivity and the features each of them have.
    In this case, I would think that C++ beats C hands down. There is really nothing that C can do which C++ cannot. I'm not talking about simple lines of code here, but larger abstractions.
    In the best case, C++ can offer a lot of things and make the programs simpler, meaner and faster. In the worst case, it can be a glorified C compiler, albeit with better type checking and better static checking tools.
    Nothing I've seen in this thread seem to dismiss this.

    The second side is the real world, really. There is different platforms, timing constraints, budgets, time to market, etc, etc, etc. There might not be a C++ compiler for a platform. That means you'd have to build one, or stick to C. Or the C++ compiler might be vastly more expensive than the C compiler. Or, there may be a choice between different architectures where an architecture that supports C++ is vastly more expensive.
    Then there's the fact that all the programmers might be hard code C programmers who do tons of implicit conversion to/from void and have a big difficulty grasping how to do explicit casting C++ requires, and so on.
    Then there are support tools, code coverage, guidelines, time to market, etc, etc.
    It often becomes a tradeoff between the total cost and time to market. If it weights in favour of C, then that's what companies would choose. Ditto for C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  15. #45
    Registered User
    Join Date
    Oct 2006
    Posts
    2,142
    Quote Originally Posted by Neo1 View Post
    Unless you're writing a C++ compiler :-)
    using the following code, and compiling with both C and C++ compilers on fedora 15 x64 (gcc and g++ 4.6.3 respectively, with -O3 on both, and -std=c++0x enabled on g++):

    Code:
    #include <stdio.h>
    
    int main()
    {
      printf("Hello, World!\n");
      return 0;
    }
    the commands I used were
    Code:
    time gcc -O3 -c test.c
    time g++ -O3 -c test.cpp -std=c++0x
    I saw nearly identical compile times, fluctuating within a millisecond of each other, around 6ms each. obviously, compiling standard-compliant C code on a C++ compiler is no slower. this is a very minimal example, but I'd venture a guess that if you use only C features, it will take roughly the same time to compile with a C++ compiler, even for larger programs.

Page 3 of 6 FirstFirst 123456 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