Thread: C or C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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
    Chappell Hill, Texas
    Posts
    2,337
    You should learn them both. Lots of common aspects between C and C++.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    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をこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by Elysia View Post
    Learning both languages is silly.
    C/C++ are merely different aspects of the same language. You can write a real world application without C++, but you cannot write a real world application without C. Learn both.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    15
    While you people debate on what's silly and what's not, I got a couple of questions...



    1) Is learning C, then C++, the best way to go ?

    2) When you say learning them both is silly, do you mean learning both at the same time ?

    3) When you say learning them both, do you mean learning both at the same time ?

    Thanks!

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Exutus View Post
    While you people debate on what's silly and what's not, I got a couple of questions...

    1) Is learning C, then C++, the best way to go ?

    2) When you say learning them both is silly, do you mean learning both at the same time ?

    3) When you say learning them both, do you mean learning both at the same time ?

    Thanks!
    I guess everyone will give their own answer, but based on watching this same debate here a bunch of times, my impression is that people are (mostly) presenting the way they learned as the way to learn.

    A couple of things are clear:
    1. if you want to learn C++, you do not need to learn C first. Just start studying C++.
    2. if you want/need to program in both languages, you might as well study both of them. You could do that at the same time, or consecutively, according to your fancy.
    3. since C++ includes most C syntax (altho there are some small differences), once you have this basic syntax down, the difference between the two will be about how you use the syntax to accomplish a goal. Related to this is the use of common libraries, which differ.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #8
    Registered User
    Join Date
    Nov 2009
    Posts
    15
    Then should one then learn Assembly, then C, then C++ then ?

  9. #9
    {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).

  10. #10
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    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.

  11. #11
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    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.

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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.

  13. #13
    {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?

  14. #14
    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?

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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.

Popular pages Recent additions subscribe to a feed