Like Tree32Likes

C++ vs C

This is a discussion on C++ vs C within the General Discussions forums, part of the Community Boards category; Elkvis, what i meant was that there is just one single case where C++ having all these advanced features do ...

  1. #46
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Elkvis, what i meant was that there is just one single case where C++ having all these advanced features do not help development time: When you're writing a C++ compiler. It was a poor attempt at humor, that is all.

    I would however like to see if there is a noticeable difference in compile time between some advanced piece of software written in C, and the same piece of software implemented using C++ with all the new C++0x extensions. But i guess they wouldn't be the same piece of software at all under those conditions, so the comparison wouldn't be very accurate anyways.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  2. #47
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    arguments should be supported by claims - which you have provided here
    O_o

    I didn't make any claims that haven't been repeated every time this notion is discussed.

    My point was that there is also a cost to all this complexity.
    I would however like to see if there is a noticeable difference in compile time between some advanced piece of software written in C, and the same piece of software implemented using C++ with all the new C++0x extensions.
    Are you an adult? Do you know the difference between fantasy and reality?

    Fact(0): My website runs on the "Drupal" CMS.
    Fact(1): "Drupal" is written in PHP.
    Fact(2): The "Drupal" source is mostly canonical PHP.
    Fact(3): The "Drupal" source is mostly of average quality.
    Fact(4): My website runs nicely on a shared virtual host along side about 190 other sites.

    What part of your brain is telling you that the cost of compilation is significant versus the benefit of solving the problem at hand?

    Fire that part of your brain. It isn't doing its job properly.

    A cost of ten minutes, actually seconds, waiting on my C++ compiler to generate a binary for the generic, expressive, RAII heavy code I write is insignificant when measured against the time I'd spend following the best of C practices to solve the same problem those features solve.

    Fact(5): Solving complex problems is the bread and butter of computers; getting a computer, a compiler, to solve a problem by means of exposing expressive generative syntax is not a cost in complexity but a benefit in productivity.

    I'd much rather use Haskell over C++ for some stuff. Haskell is spectacularly expressive for its field, and in its field it shines.

    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.
    How is this an issue for C++?

    That isn't an issue for most any language.

    Sure, some languages force crap on the programmer, but even then knowledge of every facility is never necessary.

    My mastery of the C++ generic mechanism is disturbing. I know parts of C++ as it lives in the wild that only a handful of people ever need to know.

    And isn't that wonderful? (Oh, not that I know a lot of almost entirely useless bits of C++. That's just kind of pathetic.) You don't need to know that stuff. Ever. You can make great use of C++ without ever needing to understand how to specialize a template.

    If C++ had a thousand more features and yet forced you to know none of them, would it really matter it the language specification was bloated?

    Have you ever read, not searched, the C++11 standard? I only ask because, the language and library already are bloated. It just doesn't matter; you don't have to use every method `std::string' (actually a `typedef' of a `template') has just because it has those methods.

    The same is true for most languages. Sure, I need to know the stuff the language forces me to know, but I don't need to know everything.

    Heck, I've programmed in PERL for many, many years. I'd say I know almost nothing of it, yet I've used it successfully to produce dynamic websites many times.

    Full disclosure: my PERL is very C++ structured; PERL masters mock my inability to create idiomatic PERL.

    Why do so many places say that mixing C code in C++ code is dangerous?
    It isn't. Writing bad code is dangerous; that can easily be managed in either language.

    I'd guess that the claim is making an assumption towards it being harder to write dangerous code in C++.

    Soma

  3. #48
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,581
    It's not difficult to conclude there would be a noticeable difference between compilation times. C compiler would be greatly slower if it tried to emulate C++ classes and templates, C++ would be greatly slower if the C version didn't try to use them (ignoring for a moment that this could put C in trouble).

    But, I'll be damned if I ever chose a programming language based on the compilation speed.
    Elkvis likes this.
    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.

  4. #49
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    But, I'll be damned if I ever chose a programming language based on the compilation speed.
    I, for one, plan to cut out the middle man, so to speak, and start "typing" the instructions directly into a hex editor.

    Soma

  5. #50
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by phantomotap View Post
    Are you an adult? Do you know the difference between fantasy and reality?
    Ah yes, argumentum ad hominem, the staple of any worthwhile Phantomotap post.

    How is this an issue for C++?

    That isn't an issue for most any language.

    Sure, some languages force crap on the programmer, but even then knowledge of every facility is never necessary.

    My mastery of the C++ generic mechanism is disturbing. I know parts of C++ as it lives in the wild that only a handful of people ever need to know.

    And isn't that wonderful? (Oh, not that I know a lot of almost entirely useless bits of C++. That's just kind of pathetic.) You don't need to know that stuff. Ever. You can make great use of C++ without ever needing to understand how to specialize a template.

    If C++ had a thousand more features and yet forced you to know none of them, would it really matter it the language specification was bloated?
    Here's an idea, let's cram more and more stuff into the language specification until we have, let's say 1 or 2 compilers left who is even remotely close to a complete implementation of the standard. And then let's keep doing it until none of them is. It won't matter, what are standards for anyways right?

    Have you ever read, not searched, the C++11 standard? I only ask because, the language and library already are bloated. It just doesn't matter; you don't have to use every method `std::string' (actually a `typedef' of a `template') has just because it has those methods.
    No i haven't. You know what else i haven't done? I never said that every feature of a programming language should and must be used by everyone, so why are you arguing this? I also never said that compile time was critical in any way whatsoever, i just mentioned it as one of the consequences of COMPLEXITY, which is something you seem to think is an unconditionally good thing, under all circumstances, no exceptions.

    Here is an idea, i'll go read the C++0x standard from cover to cover, and you sit down and try really hard to reply to this without being degrading and insulting. I bet i'll finish first.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  6. #51
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,581
    Quote Originally Posted by Neo1 View Post
    Here is an idea, i'll go read the C++0x standard from cover to cover, and you sit down and try really hard to reply to this without being degrading and insulting. I bet i'll finish first.
    This I can somewhat agree. Syntactic sugar additions I find should have been instead replaced by better IDEs.
    But otherwise it's simply impossible for C++ not to add new functionality. We face new computing challenges. The language needs to keep up, considering its target audience.
    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.

  7. #52
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    [Edit]
    Ah yes, argumentum ad hominem, the staple of any worthwhile Phantomotap post.
    I've been thinking about this.

    You know, I honestly didn't mean it the way you took it, but sure enough, looking at it objectively I can see you'd take it as an meaningful insult.

    So, you right; I apologize for framing the comment as an insult regardless of the intent; I intended no insult, and I'm sorry that you took it that way.
    [/Edit]

    Ah yes, argumentum ad hominem, the staple of any worthwhile Phantomotap post.
    O_o

    The notion that the time it takes for a bit of C or C++ code to compile is in any way significant is a complete fantasy.

    I wasn't saying "You are a child who can't tell the difference between fantasy and reality.". That would have been a personal attack without relevance to the argument.

    I said "You should know that the time spent developing a bit of software is far more significant than the time spent waiting on a compiler to produce a binary.".

    You did frame the time it takes a bit of C or C++ code to compile as being a significant consideration. You are also the one who forwarded the assertion that C probably beats C++ in the area of time it takes a bit of code to compile. (How about you not trying now to otherwise pretend? The posts are not that old.) It doesn't even matter if you are right. The time spent waiting on a C or C++ compiler is insignificant when measured against either the time spent developing a bit of code or benefit of having a computerized solution to the problem at hand.

    In other words, the metric of "time to compile a bit of C or C++ code" is a completely meaningless metric when evaluating a language, and you should be aware that it is a completely meaningless metric when evaluating a language.

    I never said that every feature of a programming language should and must be used by everyone, so why are you arguing this?
    What you did is to contrast the nature of features within a language and catalog new ones as either "exciting" or "bloat".

    Unfortunately, the logic of your contrast and catalog is a corrupt fantasy.

    If you don't personally use or wish to make use of a feature of a language, you are far more likely to see that feature as "bloat" instead of "exciting".

    If a C programmer has no interest in using "OOP" facilities and the "generics" mechanisms of C++ he is almost certainly going to view those features as "bloat" whether or not he is considering turning to C++.

    Do you not agree?

    It is almost certainly the case that if the standard doesn't keep expanding, regardless of how a given programmer classifies a new feature, the C++ language will die.

    Hence my response: if you don't want to use a feature you consider "bloat", you usually don't have to even know anything about that feature.

    I, and pretty much every other C++ programmer, want to see the language evolve "bloat" be damned.

    I want to get the features I want in the new standard, and I am usually perfectly happy that others should do the same.

    Syntactic sugar additions I find should have been instead replaced by better IDEs.
    Why?

    Why would you rather rely on the expressiveness of a language coming from an IDE rather than the language itself?

    I've seen this argument from a lot of people.

    I understand, and even agree usually, with the argument that features should be made as library only additions so as to avoid otherwise unneeded additions into the core language.

    However, the expressiveness of a language is one of the top reason I choose between two languages, when I have any choice at all, so I simply don't get the argument against "syntactical sugar" in core.

    We have a hard enough time getting consistency between compilers with perfectly standard code; do you have any idea how difficult it would be to get Microsoft to implement a bit of "syntactical sugar" born of "KDevelop" if it wasn't considered part of the core language?

    At this point the "other side" usually argues something along the lines of "It doesn't matter if other vendors support a bit of "syntactical sugar"; the IDE can produce conforming code when saving the file."

    If you were considering that, why don't others who may contribute to your code also deserve to use the "syntactical sugar" version without needing to buy a specific IDE?

    Soma
    Last edited by phantomotap; 12-05-2012 at 08:16 PM.

  8. #53
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,501
    Is anyone else getting this vibe: http://cboard.cprogramming.com/brief...-anyway-2.html

    It's always a sad day when one has to justify why they use C instead of C++ on a C programming website.
    Fact - Beethoven wrote his first symphony in C

  9. #54
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    It's always a sad day when one has to justify why they use C instead of C++ on a C programming website.
    O_o

    Well, actually, this is C and C++ programming website.

    And as far as I can tell, no one has asked any C programmer to justify their reasons for programming in C.

    I think the only request for justification has been for the "C++ > C" thing.

    *shrug*

    Maybe the syntax is too ugly.

    Maybe you don't think it offers you anything you need over C. (Heck, maybe it doesn't.)

    Maybe you don't know C++ and would rather stay with something familiar.

    Maybe you don't know C++ and would rather venture beyond a family language if you learned another language.

    Maybe you have a lot of tools that "know" C but "know" nothing of C++.

    Maybe you are a newbie struggling with C and find C++ entirely overwhelming.

    Maybe the industry you work for is exclusively C.

    I could give a lot of reasons.

    But really, who cares?

    C++ is a better language than C. (C++ is better than a lot of languages.) That doesn't make C++ the only language. That doesn't guarantee that C++ is the more suitable language in any given set. That doesn't make C worse C++. That doesn't make C++ the best language (Which, unfortunately, does not yet exist.).

    I know C++ very well. I do great C++ work. If I reach for general purpose programming language to solve a problem, the first language I go for will almost always be C++. You want to know one more thing about me? (Yeah, I know you don't, but I'm making a point so stay with me.) I find C++ to be disgusting mess of sin and syntax. I don't go for C++ because it is pretty. I don't go for C++ because I know it. (I've done a lot of programming in Python. I could easily see myself going mostly Python sometime in the next few years if they continue to improve it. I certainly know enough to solve any problems I come across with Python that I could also solve with C++.) I really do reach for it because it honestly has an amazing set of tools and generally stays the ........ out of my way while I use them. I get to design and implement a facility exactly as I find it to be best expressed while the language politely shuts the ........ up and let's me do my job by making use of all those tools.

    So, yeah, nothing wrong with being a C programmer. That doesn't really change anything. C++ is a better language than C. There is nothing else to say for it, but that's also all it means. If you are reading so much into that as meaning that you need special justification to use C you've overburdened a simple matter. There are a lot of real world reasons to use C, but C++ not being better than C is not one of them.

    Soma
    Last edited by phantomotap; 12-05-2012 at 10:07 PM.

  10. #55
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,501
    I use C to program PIC microprocessors for work. If Microchip suddenly threw all its support behind C++, I probably would learn C++. I have a deep respect for C++ and will most likely learn it one day -> Who knows, I might skip it and go straight to C# :P

    The reason I started making programs on my computer in C is so that I can become a better C programmer for work - Not because I wanted the "best" computer programming language, but just for practice.

    You have raised another question though, phantomotap: Python Vs. C++
    stahta01 likes this.
    Fact - Beethoven wrote his first symphony in C

  11. #56
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    Python Vs. C++
    O_o

    As in "Which is better: Python or C++?"? C++

    A language that doesn't let me make a generalized function for an arbitrary expression or semantic statement and specialize the procedure (algorithm) and structure (data) independently at my leisure without burdening me with the repetition of details can't be better than C++.

    Though, it must be said, Python has evolved considerably in this direction in the last few years. It is very good. I find myself very, very near the face a problem. The largest hurdle in my migration to mostly Python, in this direction, is the lack of certain operator overloads. (I'd still like to be closer to the problem.) Don't get me wrong, Python operator overloading is ugly, but comparing the operator overloading of C++ and Python is pretty silly considering they are just two different flavors of awful.

    Full Disclosure: CLOS has a more expressive and capable approach to exactly what I'm referencing above than C++. Unfortunately, CLOS reminds me too strongly of my old dog; it is constantly getting in my way. (It may also pee on my floor. I'm not really sure as I no longer let CLOS in the house.) I often find myself wondering if the best language would not be found by gutting everything Common Lisp from CLOS and carefully adding the remainder to Ada. (Yes, if you know anything about either language, that is truly frightening. However, you have to admit, this terrible offspring would be marvelously, almost insanely, capable of expressing intent without messing about describing things like "what", "how", or "when".)

    Soma
    Last edited by phantomotap; 12-05-2012 at 11:13 PM.

  12. #57
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,501
    Python Vs. C++

    Which one can you develop faster on?
    Fact - Beethoven wrote his first symphony in C

  13. #58
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    Which one can you develop faster on?
    (I'm assuming that we are talking about completely new code.)

    C++

    Unfortunately, Python forces me to write more boilerplate stuff than C++ to get the type of behaviors I enjoy which corresponds with the way I view problems and arrange solutions.

    [Edit]
    Just to be clear, this first bit here doesn't matter in the real world. In the real world I would always reach for my own code libraries, for Python and C++, which basically eliminate the boilerplate stuff.
    [/Edit]

    Beyond that, Python doesn't get me as close to exactly expressing the solution as I see it as C++. I sometimes have to find alternative means to express an ideal feature or relationship. You could chalk that up to my refusal to use canonical approaches where I can get the behavior I desire. Still, it takes time to consider the alternatives.

    [Edit]
    I fear this also needs an explanation.

    It often takes me more time to write code than it would any other developer with similar experience as I am almost uniquely prepared to spend time and effort on expressive implementations of a solution.

    I'm not saying that no other developer cares for the quality of their code. (That would be silly.)

    I'm just perpetually at the "I really don't care how long this takes." level so I'm more likely to research ways to express exactly what I want instead of simply reaching for a canonical equivalent.
    [/Edit]

    Soma
    Last edited by phantomotap; 12-05-2012 at 11:59 PM.

  14. #59
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,501
    So even though Python is a higher level language, you can develop programs with C++ faster

    Does that mean that C++ is better as a language than Python?
    Fact - Beethoven wrote his first symphony in C

  15. #60
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,834
    *Intermission*
    /me goes to get another box of popcorn from the concession.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 4 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