Thread: Why use C when you can use C++?

  1. #16
    Registered User
    Join Date
    Nov 2003
    Posts
    3
    Originally posted by IceBall
    As Jacob Navia (developer of the lcc-win32 compiler) wrote in a (great) C-Tutorial: and as C++, Delphi, Java, and many others came and faded
    When did C++, Delphi and Java fade? And when was someone going to tell the programmers of those languages? Seriously though, the rest of that quote actually makes some very good points. But as others have said and hinted at, people will almost always argue that there language is "the best".

    I happen to like C++ because i like the classes and the templates, but it isn't a better language than C, just a different one.

  2. #17
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    1 Huge reason people still learn C: There is much code out there still written in it, and if no one learned it, who would maintain the huge amounts of C code in the world?
    Do not make direct eye contact with me.

  3. #18
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Originally posted by frenchfry164
    I think it's mainly just preference. Go to a VB programmer and tell them that VB sucks and they'll argue.
    I program in VB. I won't argue.

    ...of course, I also prefer C++, so maybe you can't call me a VB programmer.
    Away.

  4. #19
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    I'm a VB programmer. I'll argue with you.

  5. #20
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I don't see why people bash VB so much. It's great for whipping up nice looking win32 applications extremely quickly (time is money), you can still access other libraries (i.e u can make graphical renderings with OpenGL in VB, as well as with direct3d). About the only thing is isn't suited for is intense 3D games (because of speed), but you can still even make some pretty sweet games with VB. As a side note I hated VB, I did the Visual Basic 6.0 programming book in 10th grade and just found it so damn boring making database applications, but I understand why people do like it and use it.

  6. #21
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    the speed differences can most always be attributed to incorrect use of C++.
    That is not true. C++, in some performance instances, does in fact tend to be slower due to how it's compiled and how it handles data-- BUT that is _not_ (I repeat NOT) a fault of the language-- it is a fault of the existing compiler technology.

    The real difference between C and C++ is not in the compiler, or the code-- it's in the developer. C requires a more structured mind. Whereas C++ allows a less-structured mind to take advantage of its capabilities. This was the _sole_ reason Bjarne Stroustrup (I know him) created C++. To abstract it, because he couldn't stand the discipline involved in straight C.

    C++ is fine, I've used it. However, I still prefer C, because I am closer to the machine. Nothing escapes my understanding or touch, while most C++ programmers today understand very little about how their code even executes. Likewise, real debugging is beyond most C++ developers because they can't understand what's going on in the voluminous layers of library code between them and the machine. If they have to look at assembler, or find mistakes in their compiler, or even the monitor (o/s-level debugger), they are lost to all but the most absolute basic mysteries.

    The simple analogy is this:

    User A uses C, a kit-built ferrari.
    User B uses C++, a drive-off the showroom-floor ferrari.

    Both can steer, pull levers, push pedals, push buttons, and get where they want to go at approximately the same speed.

    However, if a C++ person's ferrari breaks down, they have to call a tow-truck if it isn't simple like a busted headlight or an oil change or a flat tire.

    The C person, however, hops out, pops the trunk and grabs his toolbox, where he can fix whatever's broken, because he had to build the ferrari in the first place-- he knows where the parts are, what they do, and how they do it.

    ---

    Because of this, business tends to argue that a C++ programmer will be more effecient than a C programmer because it is perceived that the C++ programmer, having less knowledge & skill overhead, can generate code faster, meaning more progress ('cause stuff is already done for them by the compiler maker's class libraries).

    My counterargument is that overall the C programmer will be superior, albeit a slightly longer ramp-up period, because although he has to build his toolbox to suit the business, once it's built he will provide a much higher quality, more effecient, faster, smaller, tighter product, than an equivalent C++ developer, and the C programmer will actually be able to fix it himself, quickly, when it breaks.

    IMHO.
    It is not the spoon that bends, it is you who bends around the spoon.

  7. #22
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    that's humorous.
    Bjarne Stroustrup (I know him)
    the quote that you're arguing with was basically taken from the mouth of Stroustrup! I was thinking about that when I typed it actually! If I can find the context I'll show it to you.

    edit:

    here: http://www.research.att.com/~bs/slashdot_interview.html

    His answer to question 2 in particular.
    Last edited by FillYourBrain; 11-17-2003 at 03:35 PM.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  8. #23
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    by the way, I am quite capable with debugging both C and C++ ( and learning Ada now ). I see no evidence that C coders are in any way superior (if you choose to generalize that way, which I do not).

    C is a simpler language as it contains less. C++ essentially contains C. If you used only the C part of C++ where is the overhead? Answer: there is none. The additions are the only point of possible contention and I have yet to see a demonstration that showed performance differences that was not based on poor use of the language.

    To quote your buddy Bjarne:
    That said, I think the main problem is educational. Many simply have seriously inaccurate ideas of what C++ is and what can be done with it. Often "inaccurate ideas" add up to a strong disincentive to learn.
    Last edited by FillYourBrain; 11-17-2003 at 04:29 PM.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #24
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    isn't most of this famous 'overhead' mostly housekeeping stuff such as virtual tables when inheritance is used? I can see how there probably is some overhead, but as you pointed out FYB, it doesn't really matter.

  10. #25
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    virtual function pointer tables are basically an offset to a function pointer which will have to be dereferenced.

    Consider the C alternative to virtual functions.

    1. a switch or if statement based on a "type" variable to decide what code to execute
    2. a function pointer to a C function

    In either case C has the same overhead. So when people talk about virtual function pointers having overhead they're ignoring the context which they are used in. Any methodology for accomplishing that goal has the same overhead.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  11. #26
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I actually started implementing a rendering API (no, not low level stuff, it was for accessing GL and DX with the same basic high level commands) which was basically a C structure with a cow manure load full of function pointers, and their addresses were initialized at start up based on a RENDER_API enumeration. Then I remembered about inheritance and that nifty little thing called polymorphism, and I felt like the loser that I was destined to become

    but it's okay I get my bad habits from reading through the quake source code and obviously everybody that reads through the quake source code is cool becaues john carmackle was l337 (90210)

  12. #27
    Registered User
    Join Date
    May 2003
    Posts
    161
    User A uses C, a kit-built ferrari.
    User B uses C++, a drive-off the showroom-floor ferrari.
    This can be easily reinterpreted to favor the C++ crowd:

    User A uses C and rebuilds his entire ferrari whenever he wants a new one.
    User B uses C++, builds one ferrari and then builds a machine that can be used to refabricate the pieces for whenever he wants a new one.

  13. #28
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    honestly I see no point for the contention between the "crowds". If you're a one language programmer, you are a narrow shmuck and not a programmer.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  14. #29
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    Originally posted by FillYourBrain
    honestly I see no point for the contention between the "crowds". If you're a one language programmer, you are a narrow shmuck and not a programmer.
    Yeah I can just imagine putting that on my resume.


    SKILLS: I know C.


    I bet the job offers would just be rolling in

  15. #30
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    but FYB once you learn a language the others are pretty easy to pick up.

Popular pages Recent additions subscribe to a feed