Thread: C++ vs C

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    4

    C++ vs C

    I am not to sure where to put this post but here goes, i have been programming in other languages such as visual basic for sometime now and feel its time to move on to something else such C/C++.

    Which would be better to learn? I am sorry if this is a well asked question. This is my first post also .

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It depends on why you want to learn another language and what you want to do with it. Either would be a perfectly valid choice in general.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    C is old and not object oriented. I'd go with C++ first. The basics of both languages are the same anyways, so you'll actually be learning both at the same time. C++ is also virtually the same as Java, so if you wanted to move to Java and you know C++, it's a walk in the park.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> The basics of both languages are the same anyways, so you'll actually be learning both at the same time.
    But the techniques and best practices for each are different enough that you really should consider them separate languages.

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Go ahead and learn C++.

    C is essentially a subset of C++, so if you know all of C++, then you know C too.

    The main conceptual difference is that C++ is object oriented. If you only learned C++, and no other programming languages, you would not know how to write a C program, because you can't use classes & objects in a C program. In your case, you already know how to write procedural (non object oriented) programs.

    There are several things that make C++ "easier" than C (you can do things with less lines of code). But overall, C++ is more complicated/complex... There is just more to the language. In fact, it's so complex that you can't even find a reference book that covers the entire ANSI/ISO C++ language, except for the language standard itself!

    ...i have been programming in other languages such as visual basic for sometime now...
    In case you don't know this already, there is nothing "visual" in ANSI/ISO C++. All GUI/Graphics are done with additional 3rd-party libraries. So, most "students" start-out with command line programs to get a good grasp of standard C++ before moving-on to graphical programs. (And, "Visual C++" is not a language, it's the name of Microsoft's C++ compiler. Of course, it includes the additinal libraries for making GUI programs.)

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by DougDbug View Post
    In fact, it's so complex that you can't even find a reference book that covers the entire ANSI/ISO C++ language, except for the language standard itself!
    Nor is there a single complete and fully compliant implementation (read: compiler + standard library) of C++.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'd say that for proper advice, we need the answer to Daved's question: What is the purpose of learning another language, what type of applications/machines are you thinking of working on?

    Almost every type of application can be programmed in either C or C++, but some tend to match better in one than the other.

    As to the comments that C++ is based on C, thus if you know 100% of C++, you also know C - that is true and false at the same time. Yes, if you know 100% of C++, you can understand C. But writing code in C++ is very different from writing code in C - well, at least if you use C++ as it was intended to be used, rather than as a "slightly better C compiler".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    It's a bit like Spanish and Italian. The languages are similar enough that if you know one very well, you'll be able to sort of understand the other. Doesn't mean you can speak it, though.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    4
    Thanks for all the help, i would be hoping to use C++ for programming games and other useful software once i understand the language.

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    C++ is quite often used for games, and is very suitable for that. Likewise for other "PC" applications.

    C is often used for smaller projects and for embedded products for example.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    4
    I will start with the lessons on cprogramming and see how i get on.

  12. #12
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    This is also a decent one.

  13. #13
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    That site's moved up a bit.

  14. #14
    Registered User
    Join Date
    Oct 2007
    Posts
    4
    Thanks Yarin that site looks really good.

Popular pages Recent additions subscribe to a feed