C or C++

This is a discussion on C or C++ within the General Discussions forums, part of the Community Boards category; If I got it right C# is basically meant for the Windows OS. But what are the differences exactly between ...

  1. #1
    Learning C. JOZZY& Wakko's Avatar
    Join Date
    Nov 2009
    Posts
    59

    C or C++

    If I got it right C# is basically meant for the Windows OS. But what are the differences exactly between C and C++ and what would be better to learn?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    You should learn them both. Lots of common aspects between C and C++.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Agreed. If you are going to learn either C or C++, you might as well learn both. They are used heavily together. C code is very often mixed in with C++ code, especially in legacy code if you ever have to go and read legacy code for any reason.

    C# is primarily for Windows, but it has been ported to Linux as well. I assume since it has been ported to Linux, you can also write C# code for for Mac OS X...but that is pure speculation on my part.
    My Website

    "Circular logic is good because it is."

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,587
    Learning both languages is silly. You want to learn either. When learning C++, you would also like to learn something of its low-level basics, which is normally inherited from C, but with some differences.
    What to choose? Well, aside from the whole what you like best argument, for anything but stubborn integrated platforms, I would choose C++ simply because it is much more powerful and flexible than C, and is a more modern variant of 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.

  5. #5
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    On the other hand, however, C++ is still very bloated and slow by comparison. So, if you desire to go into embedded work, I would recommend C. And, BTW, C is more powerful than C++ and is the modern language of choice (in certain circles).

    I guess the point here is that it is asinine to say "C is better than C++" or "C++ is better than C" as each has a place in the world. No one language is complete enough to handle EVERY task easily (though almost any language could handle any task -- just may not be tooled for it).

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    I can already see where this thread is going. Another C vs C++ debate incoming...
    bit∙hub [bit-huhb] n. A source and destination for information.

  7. #7
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    C# is primarily for Windows
    More accurate to say the C# is primarily for the .NET platform, which is primarily for Windows. It was intended to be a multi-platform virtual platform, like Java, but in practice that hasn't really happened. Mono, exists, which is a Linux implementation of the .NET framework, and apparently it's improved greatly over the years. But unless I'm horribly out of the loop, it's certianly not mainstream.

    In any case - comparing C# to C and C++ can get kind of silly, anyways. I also think that C and C++ are diverging more and more, it used to just be a matter of having classes and not having classes, but now they have two extremely different styles.

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,587
    Hehe. Yes, it always turns out that way, does it not?
    But right now, I have some myths to bust. C is not better than C++. It is not faster than C++. Bloated is subjective. I would prefer to see it packed with a lot of useful features.
    C++ is as fast as C, or faster. C is also just as fast as C++, or faster. It depends on how you use it and where.
    And while you say is more a powerful language choice in certain circles, I find that to be a very bold statement. Sure, C is preferred in certain areas, but I do not know if I would exactly call it a modern language or more powerful. Usually there is a reason for C, but more powerful? I simply do not know.

    But the point I was trying to make is this: C++ will usually get the work done faster than C, so it gets the upper hand (this may change depending on experience, of course, since it is subjective), so if there is a choice between learning C and C++, C++ is usually the better choice IMHO.
    Of course, this also depends on where you want to write your code. Embedded systems usually only have C compilers. API is still C or Obj-C, but is still accessible from C++.

    It is simply a choice of preference.
    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.

  9. #9
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Quote Originally Posted by Elysia View Post
    Hehe. Yes, it always turns out that way, does it not?
    But right now, I have some myths to bust. C is not better than C++. It is not faster than C++. Bloated is subjective. I would prefer to see it packed with a lot of useful features.
    C++ is as fast as C, or faster. C is also just as fast as C++, or faster. It depends on how you use it and where.
    And while you say is more a powerful language choice in certain circles, I find that to be a very bold statement. Sure, C is preferred in certain areas, but I do not know if I would exactly call it a modern language or more powerful. Usually there is a reason for C, but more powerful? I simply do not know.

    But the point I was trying to make is this: C++ will usually get the work done faster than C, so it gets the upper hand (this may change depending on experience, of course, since it is subjective), so if there is a choice between learning C and C++, C++ is usually the better choice IMHO.
    Of course, this also depends on where you want to write your code. Embedded systems usually only have C compilers. API is still C or Obj-C, but is still accessible from C++.

    It is simply a choice of preference.
    I guess the word irony is not in your lexicon, eh?

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,587
    It is, if you make it obvious your post looks like irony, which it did not.
    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.

  11. #11
    Learning C. JOZZY& Wakko's Avatar
    Join Date
    Nov 2009
    Posts
    59
    So it basically comes down to the following questions.

    1. Is there anything in C that you can not do in C++ or the other way around.

    2. Would that one be best to learn then when you just want to write basic programs to begin with for a Windows or Linux platform?

  12. #12
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,587
    1) Yes, there is plenty that can be done in C++ that cannot be done in C (or at least not in any easy and fast way). I know there are a few things that C can do, but C++ cannot, such as variable-sized arrays, but aside from that, I am not really sure. Regardless, C++ has the big upper hand in this question.
    2) I would argue yes. If you use the high constructs of C++, it is very easy to get started writing simple programs. I especially like Accelerated C++ which demonstrates such a way. Using C, it would take a while to get started due to its lower complexity. However, that complexity also exists in C++, but usually it can be abstracted using higher-level methods and/or functions.
    Last edited by Elysia; 11-04-2009 at 01:13 PM.
    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.

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    If you're just writing basic programs, I'd choose C++ and learn it as C++ (and not C with classes as many books/tutorials teach).

    But either choice would be fine.

  14. #14
    Learning C. JOZZY& Wakko's Avatar
    Join Date
    Nov 2009
    Posts
    59
    Quote Originally Posted by Daved View Post
    If you're just writing basic programs, I'd choose C++ and learn it as C++ (and not C with classes as many books/tutorials teach).

    But either choice would be fine.
    Does it also not matter if you at a later stage want to build programs that use a network connection?

  15. #15
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Networking libraries are plenty for both.

Page 1 of 5 12345 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