View Poll Results: Is C better than C++

Voters
28. You may not vote on this poll
  • Yes, C is better

    8 28.57%
  • No, C is not better than C++

    20 71.43%

C better than C++? (POLL)

This is a discussion on C better than C++? (POLL) within the A Brief History of Cprogramming.com forums, part of the Community Boards category; "Clyde, there IS C code that is not C++ code. It is possible to write perfectly legal C that won't ...

  1. #16
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,420
    "Clyde, there IS C code that is not C++ code. It is possible to write perfectly legal C that won't compile in C++. "

    I stand corrected.

  2. #17
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    Yes, there are instances of C does that is not C++. Stricter type checking, and a few subtle differences in grammar make these c++ no-no's:

    Implicit int
    assignment of int to enum
    definition of struct in return type/argument type
    calling function without previous declaration
    function declared without argument types can take any arguments.
    specifiy types of arguments after list of arguments
    use a void* as rhs of pointer assignment (unqualified malloc())
    Global const variable having external linkage
    nested struct declaraction placed in scope of nesting struct
    longer initialization of array than array has elements

    There are also silent differences, obscure code that is valid in both languages, but does different things. This is irritating in that a compiler might not catch them. They are, however, unlikely in real code.
    Code:
    int foo (int a, int b)
    return a //*Hmm*/b
            ;    /* This is unlikely, but it isn't proper C*/
    }
    Code:
    int x[99];
    void foo() {
    struct x {int a;};
    sizeof(x) //Size of the array in C, size of the struct in C++
    }
    Lastly, and this is kind of cheating, but you could use C++ keywords as identifiers, and use C macros that are elevated to keywords in C++ in macro logic, such as:

    Code:
    int class = 0;   /*OK in C, c++ would balk*/
    Code:
    #ifndef and
    printf("This won't print in C, will in C++");
    #endif

  3. #18
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    All valid points, and good things, many people wondered why I said those things as pro's and con's I guess i should have mentioned that this is what I heard, not what I know.

    However, I do know that the Pro and Con thing bout microsoft is true.
    Mostly a joke though.

    Thank you for all your comments and opinions, I learned a lot from this so I am sincerely gratefull
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  4. #19
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Originally posted by Lynux-Penguin
    However, I do know that the Pro and Con thing bout microsoft is true.
    Mostly a joke though.
    I still don't get it. How does Microsoft own C++? They do make
    one of the most popular compiler but VC++ is just that. A compiler.
    They don't own any bit of C++. VB is a different story. That is their
    proprietary language.

  5. #20
    Registered User
    Join Date
    Dec 2001
    Posts
    44
    Originally posted by jdinger


    I still don't get it. How does Microsoft own C++? They do make
    one of the most popular compiler but VC++ is just that. A compiler.
    They don't own any bit of C++. VB is a different story. That is their
    proprietary language.
    Importantly, VC++ isn't even a C++* compiler. For an interesting exercise... can anyone find any documentation on Microsofts site which says that they're VC++.Net offering actually compiles C++*?

    Ian Woods

    *The C++ programming language is defined in ISO/IEC 14882 as published in 1998 and often called C++98.

  6. #21
    Registered User
    Join Date
    Dec 2001
    Posts
    44
    Originally posted by Shiro
    >The purpose of programming language is to allow programs to
    >be developed more efficiently in terms of time and cost.

    That is from a managers point of view. But from a technicians point of view: the purpose of a programming language is to be able to develop software in such a way that it meets system requirements.
    And why would a technician want to meet system requirements? By definition, anything which can be implemented in any programming language on a given platform can be implemented in machine code on that platform. So, machine code allows programmers to develop software in such a way that it meets system requirements - it isn't however the most appropriate or useful 'language' to use in almost all cases.

    Importantly, it's not just the 'business case'. The issues involved and which I proposed (time and cost) are central to a business case but also have a significant effect on not-for-profit software development. Case in point: why don't you write all your software in machine code?

    I don't know about you, but I like my experimental, learning and 'fun' projects completed in a reasonably timely fashion.

    This means that in a lot of situations you don't depend on just one language, but use more languages. A small example: a mobile phone project. The very low level stuff is written in assembly (OS level and below OS level), the low level stuff is written in C and C++ (OS level) and the high level stuff is written in Java (application level / GUI level).
    Indeed. I didn't want to promote the idea that any one language is better than any other: the "Depends" answer to which is best is equally true to subsystems as it is to whole projects.

    >How do you measure how productive programmers are with a
    >given language?

    The PSP has shown to be a quite good tool for measuring the productivity of programmers in different languages.
    I'm unfamiliar with 'PSP' whatever that happens to be. All performance metrics I've ran into in the real world (real development in and outside of business) depend almost entirely on:

    designer competence
    implementor competence
    co-ordinators competence
    amount of software reuse

    The only one of those which can be effected by the language features is the amount of software reuse which is possible. Obviously, these aren't of equal 'strength' in terms of getting a project done within budget (if any) or in a timely fashion (if any)... or even 'done' at all. A discussion of these (and whatever I have missed out in my simple 'stick-man' consideration of direct factors for general development would be long winded!

    >In fact, I find C 'better' than C++ for many programming projects
    >because I can achieve the project goals in less time and using
    >fewer resources. Sometimes, C++ is 'better' for the task at
    >hand.

    It also depends on the design and underlying architecture. If these are object oriented, C++ would be 'better'.
    Not necessarilly. Object oriented design methodologies do not require the use of an object oriented programming language. Indeed, making a program in C followined an object oriented design is fairly trivial in C using various techniques including opaque types and dynamic typing.

    Obviously, some of these techniques require intermediate C programmers a little time to learn whereas C++ programmers get this almost for 'free' by educating their intermediate programmers good object oriented analysis and design methodologies and concepts. That is certainly an advantage to object oriented languages - the time taken to go from intermediate to competent programmer is reduced for OO concepts to OO implementations.

    Again, this is a quite in depth and possibly never ending discussion about object orientation and how it can be implemented in non-object oriented languages. Safe to say if it produces machine code then obviously the same goal can be achieved in several/many languages.

    >2. I like the low levelness of c.

    C++ is as low level as C. It just depends on how you write your software.
    Indeed.

    >3. c if you ask me has a lot more potential the c++,

    In fact C++ has more potential. It is not only possible to write procedural C code, but also object oriented C++ code. Note that C++ is based on C.
    IMO this is another of those questions that needs clarification of terms - 'potential' in this context could mean many things. Who know's what C or C++ may become (or not become) in a decades time? It is likely that the amount of developer interest in C++ may make it appear that C++ has more potential... but then, so did COBOL.

    As far as I'm concerned, any language which is only a subjective practical improvement rather than a technological improvement is mere icing on the cake. The whole programming world does not revolve around languages: it revolves around the concepts in which programs and their designs and specifications are expressed. If I invented a language cleaner, simpler and equally as efficient as C++ then I'm not adding to the technology pile... though I might be adding to the practicallity pile. If I made a language which used a paradigm which allowed software reuse more than object orientation does, which allows your program to be proven against it's specification and is simpler and faster to program in then I /might/ be adding to the technology pile.

    How is yet another object oriented or procedural or functional or aspect oriented programming language any better or worse other than in completley practical terms over any other in it's class?

    Ian Woods
    Last edited by hairyian; 04-30-2002 at 08:45 PM.

  7. #22
    Registered User
    Join Date
    Dec 2001
    Posts
    44
    Originally posted by Imperito
    [B]Yes, there are instances of C does that is not C++. Stricter type checking, and a few subtle differences in grammar make these c++ no-no's:
    How's about:

    o variable length arrays
    o a whole new set of type generic maths functions
    o a new meaning to word 'static' (with a famous quote)
    o a number of new string processing functions (snprintf for example)
    o many new integer types (including long long, int32_t, int_least32_t and so on)
    o a boolean type whose semantics are different to C++'s
    o expanded environmental and type limits
    o a new character set abstraction
    o universal character name support (may or may not be in C++, can't remember)
    o variable argument preprocessor macros
    o the 'restrict' type specifier
    o different variable initialisation rules
    o different preprocessor defines like __func__ and a set of standard pragmas

    and I'm sure if I sat down and examined the difference between the C and C++ specs I'd come up with a few more gems. Here's a simple example of perfectly valid C code which is absolutely not C++ code:

    #include <stdlib.h>
    #include <stdint.h>

    struct foo {
    size_t len;
    int_least32_t data[];
    };


    int main(void) {
    struct foo * f;

    f=malloc(sizeof(struct foo)+sizeof(int_least32_t)*500);
    f->data[499]=42;

    return EXIT_SUCCESS;
    }

    The thing to remember is that C and C++ went their seperate ways in the mid 90's, and C has changed a bit since then and the C++ specification has also been defined.

    Ian Woods
    Last edited by hairyian; 04-30-2002 at 09:22 PM.

  8. #23
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > However, I do know that the Pro and Con thing bout microsoft is true.

    MS doesn't own C++ anymore than Bell owns C. It's an open language. MS just has a compiler for it (I'd like to see proof that it's not a compiler, hairyian, and don't jsut say that it's not ANSI compliant. I've never seen a compiler that is.)

  9. #24
    Registered User
    Join Date
    Dec 2001
    Posts
    44
    Originally posted by Govtcheez
    > However, I do know that the Pro and Con thing bout microsoft is true.

    MS doesn't own C++ anymore than Bell owns C. It's an open language. MS just has a compiler for it (I'd like to see proof that it's not a compiler, hairyian, and don't jsut say that it's not ANSI compliant. I've never seen a compiler that is.)
    That wasn't quite what I was refering to.

    If you go and take a look as MSs website and the promo text for Visual Studio .NET it's quite apparent that they don't even say it compiles C++ /at all/ and I don't mean they don't say "This compiles ANSI/ISO C++98". I mean they don't even say "This compiles C++" or even "C" or "VB". It compiles their new language Microsoft Visual C++ (R) .NET....... I was just playing jest with the notion that calling it a C++ compiler seems to be something MS are explicitely avoiding.

    As for 'conforming' compilers, Borland have been claiming their compiler is compliant for a while. Whether or not you believe them is a different matter entirely of course.

    Ian Woods

  10. #25
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >And why would a technician want to meet system
    >requirements?

    Since technicians are perfectionists. They want the thing they create to be perfect.

    And since technicians who are working at a company need to meet system requirements. They have an agreement with the customer about the system requirements, if the product doesn't meet this requirements, the product is not the product the customer wished. So the customer may say: I don't accept this. This will cost the company money.

    Why people don't write all software in machine code is mainly because of maintainability.

    Perhaps I was not clear, but what I meant to say was that you have to look from different point of views when talking about 'better'. Technicians usually want other things than managers. A manager wants his project to be succesful, which is: the project be finished in time and within the budget. A technician wants to be the product perfect from a technological point of view. This usually doesn't lead to problems if the requirements are clear. The manager knows the requirements need to be met and the technician knows there is a limited time and budget.

    I also like my home projects, but at my company I have to do projects in a different way.

    >I'm unfamiliar with 'PSP' whatever that happens to be.

    The PSP is the Personal Software Process, it's a lot of paperwork which you have to fill in. The main thing of PSP is learning how you function. When you know your weak points and strong points, you know how you can improve yourself.

    The PSP is currently mainly implementor competence. I know there are more metrics systems, but I have only experience with PSP.

    In my opinion, PSP is not always useful. For example, there is a metric in this system which is about the lines of code you write per hour. I don't think that is applicable, the lines of code you write per hour depends on the kind of task and the level of the task.

    >Object oriented design methodologies do not require the use of
    >an object oriented programming language.

    Sure, object oriented designs don't require an object oriented language, but it makes things easier. Especially when advanced concepts like inheritance are being used. I've worked on a project where we implemented an object oriented design in C. It is possible, but I think it would have taken less time when we did it in C++.

    I've heard about object oriented designs being implemented in assembly. I've never done that, but it seems quite a large project to me.

    One of the most important things I've learned in programming is programming concepts (algorithms and datastructures) and design methods, since these are language independent.

  11. #26
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    Geez...
    I could have sworn C++ was from Microsoft... in fact I am sure of it!
    IOSTREAM is owned by microsoft
    Code:
    note to self: don't tell anymore jokes
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  12. #27
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    int C = 0;
    C++;

  13. #28
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294
    Originally posted by Lynux-Penguin
    Geez...
    I could have sworn C++ was from Microsoft... in fact I am sure of it!
    IOSTREAM is owned by microsoft
    [/code]

    hahahaha FUNNY hahahha lynx stay on linux

  14. #29
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Indeed, making a program in C followined an object oriented design is fairly trivial in C using various techniques including opaque types and dynamic typing...

    snip

    ..Safe to say if it produces machine code then obviously the same goal can be achieved in several/many languages.
    True, but a creating an object orientated design in C often requires far more runtime support than in C++, where alot of the details are resolved by the compiler.

    The thing to remember is that C and C++ went their seperate ways in the mid 90's, and C has changed a bit since then and the C++ specification has also been defined.
    Not really. C++ aimed for backward capability with C, with some stronger type checking, and then C got updated in C99. C++ will incorporate most of what you mention in C++ 0X to maintain that compatibility. Although, whether vendors decide to implement it is another matter.

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

Similar Threads

  1. How do you create a Poll?
    By cpjust in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-30-2009, 11:35 PM
  2. Poll - Terrorism & Torture
    By Kybo_Ren in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 12-04-2006, 02:08 PM
  3. Hungarian Notation POLL
    By maxhavoc in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 06-21-2004, 11:52 AM
  4. Today on Cprogramming....When Polls go bad?
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 01-25-2002, 01:41 PM
  5. Poll this Poll that
    By ski6ski in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-28-2001, 05:19 AM

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