Find the answer to your Linux question:
Results 1 to 10 of 10
i am wanting to learn either C or C++, i am actually wondering what the differences are if any and which is the best to learn? I have done a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2005
    Location
    Wakefield / England
    Posts
    36

    C or C++? which one?


    i am wanting to learn either C or C++, i am actually wondering what the differences are if any and which is the best to learn? I have done a ome programming in C++ but it seems to be so long winded to get it to actually to do something! is C the same? currently i program using python!

    thanx for any advice or pointers

  2. #2

  3. #3
    Linux Newbie
    Join Date
    Jan 2004
    Location
    Houston, Tx
    Posts
    144
    In my humble opinion, I think C is the way to go. I'm going to copy my opinion over from a post I wrote on another forum to a similar question:



    I'm going to go against what everyone is saying here, and say, start with C. I think that if you start with OO, you will end up sticking with that, and there's a possibility that you'll never learn procedural programming. Of course, you can do procedural programming with C++, but most C++ books you pick up will teach you OO right off the bat.

    I have nothing against OO, obviously, I use and like Java a lot, which is heavily oriented to OO, but I personally believe that starting with OO is not the way to go. First and foremost, when writing procedural code, you are in control of your program, not some engine running in the back. I personally find it much more rewarding to be in complete control of your code rather than having your code based on some other code, which is based on some other code, which goes on and on in a nearly endless pattern.

    Secondly, writing procedural programs will force you to learn certain basic algorithms, which I believe are essential to a good programmer. It's sad, but in my Computer Science three class, there are quite a few students who don't know how to properly work a bubble-sort. Of course, this is through no fault of their own. We use Java, and it has a very simple sort() method in the Collections class, and that's all that they know how to use. They know how to use the sort() method, they don't know how it works. When learning C, you will almost definitely learn the basic sort and search algorithms.

    Furthermore, I think it will be easier to learn procedural programming as a first language than it will be to learn OO. I have seen many instances where people portray C as a cryptic language which is arduous to learn. This is not true. When your computer functions, it thinks procedurally; one task after the next. Your brain functions in a similar manner. C was the first real language I started out with, and with a good book, it's no problem to learn at all, perhaps easier than C++.

    The knowledge you gain from learning C is not going to fade out once you move on to OO, either. Learning C will teach you the fundamentals of programming, and you will carry these basic skills with you to whichever language you decide to go on to, aside from Assembly, Lisp, or some other esoteric languages like Brain****. You will find heavy application of the knowledge you gained while learning C, even when you move on to C++, and other high level languages.

    Like I said before, I have nothing against OO programming. C++ is a great language, and if that's the way you want to go, then I say go for it wholeheartedly, but in my humble opinion, I think it's better for a student to start with procedural programming and then move on to OO. Once you pick up C, you will probably be able to pick up C++ in less than a week as a second language, if you applied yourself to it. They're both great languages, and they would both be good to start with, it's really all up to you.

  4. #4
    Just Joined!
    Join Date
    Jul 2005
    Location
    Wakefield / England
    Posts
    36

    C or C++? which one?

    well thanks for that, i think i will learn C first if any one knows of any books to get me started, i would be most grateful

  5. #5
    Linux Newbie
    Join Date
    Jan 2004
    Location
    Houston, Tx
    Posts
    144
    I liked Herbert Shildt's Teach Yourselc C.

  6. #6
    Just Joined!
    Join Date
    Jul 2005
    Location
    :noitacoL
    Posts
    51
    There is only one book for C programming: The C Programming Language
    by Brian W. Kernighan, Dennis Ritchie, Dennis M. Ritchie.

  7. #7
    Just Joined!
    Join Date
    Nov 2004
    Location
    Florida
    Posts
    52
    I recommend them both(since I own both books), although The C programming language is a litle bit harder to understand at first then Teach yourself C , I would definetly go with The C programming Language. It will teach you many of the tricks of C and it will also explain you how some of the built-in functions of C are written and how to write your own versions of them.

  8. #8
    Just Joined!
    Join Date
    Jul 2005
    Location
    Poolside at the flamingo
    Posts
    1
    Quote Originally Posted by TheFourthBeast
    There is only one book for C programming: The C Programming Language
    by Brian W. Kernighan, Dennis Ritchie, Dennis M. Ritchie.
    best book ever for c!

  9. #9
    Linux Newbie
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    168
    I too think learning C is the best way to start. You should be able to get K&R's "C the Programming Language" used on Amazon at a reasonable price. You should also get "C the Answer Book" which is a companion answer key for K&R by Tondo & Gimpel.

    C isn't a large language, just a powerful one.

    Jeff
    Registered Linux User #391940

  10. #10
    Just Joined!
    Join Date
    Sep 2005
    Posts
    1
    I think that if you start with OO, you will end up sticking with that, and there's a possibility that you'll never learn procedural programming.
    I disagree. There are many elements of procedural programming within OOP.

    Of course, you can do procedural programming with C++
    ...and you can do OOP with C.

    I use and like Java a lot, which is heavily oriented to OO,
    Java is a pure OOP language. Everything in Java IS an object.

    First and foremost, when writing procedural code, you are in control of your program, not some engine running in the back.
    I think you're referring to the JVM. However, that's specific to Java and interpreted languages, not OOP.

    Secondly, writing procedural programs will force you to learn certain basic algorithms, which I believe are essential to a good programmer.
    You can learn the same algorithms using an OOP language.

    It's sad, but in my Computer Science three class, there are quite a few students who don't know how to properly work a bubble-sort. Of course, this is through no fault of their own. We use Java, and it has a very simple sort() method in the Collections class, and that's all that they know how to use. They know how to use the sort() method, they don't know how it works. When learning C, you will almost definitely learn the basic sort and search algorithms.
    C includes a sorting function in it's standard library. The issue that you raise has nothing to do with the language or programming paradigm.

    C was the first real language I started out with, and with a good book, it's no problem to learn at all, perhaps easier than C++.
    C++ is larger and definitely more complex than C.

    Like I said before, I have nothing against OO programming. C++ is a great language,
    C++ is not an OOP language -- at least not in the sense that Java is. It is a general purpose programming language that facilitates OOP.

    Once you pick up C, you will probably be able to pick up C++ in less than a week as a second language, if you applied yourself to it.
    This is nonsense. No one is picking up C++ in a week -- whether you know C or not. Perhaps you may become familiar with the syntax of C++ within a couple weeks, if you know and understand C. But to learn enough about C++ to write any substantial program could possibly take a year or so. Bjarne Stroustrup states that an experienced programmer just learning C++ could take a year to a year and a half to learn how to program in C++ effectively.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •