Thread: Learning C++..whats so good about it

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    Learning C++..whats so good about it

    is C++ worth learning.
    and what advantages does it have over C other than Visual Programming.
    from some research i have done C seems to be a little tiny bit faster.
    so is it worth learning?if so why?

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Exclamation Briefly...

    The main difference is that C++ is object oriented. You can have objects & classes. I'll leave it to others to argue that object oriented programming is "better".

    There are some other things that make C++ easier to use: cout (and cin)... cout is much easier to use than printf(). C++ has a string class, so you don't have to use null-terminated character arrays. C++ includes the Standard Template Library, which means that you can have dynamically allocated "arrays", and built-in linked-lists, etc.

    C is getting outdated. As far as I know, you can't even buy a C-only compiler for a PC... (There are some up-to-date C-compilers for some for some platforms.... i.e. embedded controllers.) If you are writing C programs, you really should "get with-it" and learn some C++ !

    On the other hand, with all of the added features, C++ is quite a bit more complex than C. And I haven't counted, but I think there are at least twice as many standard library functions in C++. Heck, (AFAIK) there isn't even a reference book will all of the C++ library functions!

    Speed - There may some cases where an object oriented program will have more overhead, and be slower than a non-object oriented structure. You can use a non-object oriented structure for speed-critical operations. I don't know much about speed optimization, but if speed is that important, you may want to use inline assembly for portions of your code. However, I understand that modern compilers are quite good at speed-optimization... You'd have to be an assembly language expert to "beat" the compiler!

    BTW - You do NOT need C++ to write "visual" programs. In fact, like C, there are no graphics/GUI functions in standard C++. All of the GUI functions are in special platform-specific libraries. The WinAPI (i.e. Microsoft Visual C++) can be used in C-only programs.
    Last edited by DougDbug; 06-10-2004 at 08:29 PM.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >>is C++ worth learning.
    Only if you want to learn it.

    >>and what advantages does it have over C other than Visual Programming.
    Its not "visual", Visual C++ is a microsoft product.
    One might argue that an object-oriented language is advantagous over a modular laguage for various reasons.
    I believe one should master C using data-structures, followed by C++ and applying object-oriented programming concepts to what you already know.

    >>from some research i have done C seems to be a little tiny bit faster.
    Both are equally "fast" when you know what you're doing and where the bottlenecks are.

    >>so is it worth learning?if so why?
    Learn it if it intrests you more than anything else of interest.

    gg

    [edit] and what DougDoug said...(minus the book reference)

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >cout is much easier to use than printf()
    I, for one, much prefer using printf() over using cout.

    >C is getting outdated.
    Hah. Why do you say that? Why do you think that many API are designed with C compatibility in mind?

    >If you are writing C programs, you really should "get with-it"" and learn some C++ !
    Learning OOP is definitely a good idea, but that does not mean that using pure C is a bad thing. If used improperly, OOP can cause significant bloat in a program, and it is quite easy to obfuscate your program far too much.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    >cout is much easier to use than printf()
    I, for one, much prefer using printf() over using cout.
    I second that.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Quote Originally Posted by Dante Shamest
    Quote Originally Posted by XSquared
    >cout is much easier to use than printf()
    I, for one, much prefer using printf() over using cout.
    I second that.
    So you've mastered C I/O..........but have you mastered C++ i/o streams?

    I once prefered printf() as well

    gg

  7. #7
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Well first post back... been busy.

    Anyway, agree with CodePlugs comments.

    I am teaching a C course this summer, actually C does have some value.

    Have you thought about Java or C#?
    Mr. C: Author and Instructor

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    I see C's value and its only at 67.

    I also see that printf takes up less line space on average than cout, but every once an while II will mix up the type specifier or forget the entire parameter, and this will typically cause my program to print out junk.

  9. #9
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    well it sounds worth learning
    i have been thinking weather or not to learn ASM or C++ ofcourse asm has far more advantages but at 15 im not really in to much of a hurry.
    from what i have seen there isnt to much C cant do and from the sounds of things C++ just makes it easier to make programs.

    on the comment on getting up to date i think C is sort of up to date.
    i mean win32 api and gtk are based around C and so are a fair bit of languages
    also theres lcc-win32 thats a pretty upto date C compiler.

    is there any other real big advantages that C++ has over C.
    as for getting a job and so on

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >i have been thinking weather or not to learn ASM or C++
    Learn both. There are valuable lessons to be had from experience with assembly language as well as C++.

    >is there any other real big advantages that C++ has over C.
    IMO, C++'s biggest advantage is good support for templates and a powerful standard library. C's standard library is lacking when it comes to containers; so you have to roll your own or use a third party library.

    >as for getting a job
    Employers seem to have forgotten that C exists in help ads.

    >I'll leave it to others to argue that object oriented programming is "better".
    Wise of you.

    >As far as I know, you can't even buy a C-only compiler for a PC...
    It's a better marketing choice to bundle a C compiler with a C++ compiler.

    >I, for one, much prefer using printf() over using cout.
    That's okay as long as you stick to printing things that printf can handle. But once you need more complex formatting or easy printing of user-defined types, iostreams begin to look more attractive.

    >Hah. Why do you say that?
    Nobody wants to learn how to write large programs in C from what I can tell. They want a magic paradigm (hehe, I used a buzzword) that solves all of their problems. That's basically what OOP has been hyped up to be. However, since I've made my opinion of OO known, I'll leave it at that.
    My best code is written with the delete key.

  11. #11
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    C is getting outdated
    Since C++ is a superset of C++ this does not matter. As long as C++ is around...C will be too because C++ is a part of C, not the other way around.

    is C++ worth learning.
    Yes. I think this board and the Windows OS itself bear witness to that. Plus, without C/C++ we would not be where we are today in the world of computers.

    and what advantages does it have over C other than Visual Programming.
    I stray away from the thought pattern of separating C and C++ as much as possible because I do not think it is technically correct. C++ is a superset of C as I said but w/o C, C++ would not exist. C++ supports a much better form of object oriented programming than the C struct. With the C++ class, container libraries, templates, etc. much more can be accomplished in less code. But it should be said that most APIs strive to be more C-like than C++. In its base-design philosophy COM is more like C than C++ - in COM inheritance is not as much of a problem in C++. There are several reasons for this and I don't have time to go into them right here. Also if you are referring to Visual Basic you will simply make me sick. VB is the ugliest code I've ever seen, its objects are the crappiest I've ever seen, and its error-handling code is pulled from a mid 80's design philosophy but is used on a 2000+ machine. It was not meant to be a structured language and no matter how hard they've tried to change that....it still isn't IMO.

    from some research i have done C seems to be a little tiny bit faster.
    True in some cases. Each class holds a virtual function table and other info that, depending on class design, can result in much more function call overhead - and overhead that is not all that apparent from the C++ code. But the performance loss is minimal compared to the structure, object coherency, polymorphism, and overall object hierarchy that is gained in a C++ program. I can't even begin to explain the benefits of C++ here...there just isn't space.

    so is it worth learning?if so why?
    Depending on what you want to do in computerdom....you will need C++ in nearly every job I can think of...unless you plan on being some, shall we say, Javaite coder. Even Java bastardizes C++ and claims to improve upon the C++ design which is quite debateable in my opinion. Games and entertainment software that have to be fast and are frame-rate dependent must use C/C++ and assembly. No ifs ands or buts about it. C/C++ and assembly are the fastest combination of languages available today on any x86 platform. For real-time software this speed can only be gained from languages like C/C++ and assembly.
    I recommend learning even basic assembly simply because it will give you a very good idea of what is going on underneath all that C/C++ code. Many, many, many, many programmers know a whole lot of C code and a whole lot of C++, but few IMO understand what is going on underneath of it all. I still shudder at some books and tutorials that randomly spout of C/C++ code with no thought of how the doggone thing will look in assembly or what they are forcing the compiler to write in assembly.
    Assembly will give the baseline understanding of the Von-Neumann architecture and the x86 architecture. C/C++ was designed to be able to accomplish anything that could be done in assembler.



    My advice...learn assembly and learn it well. Learn C/C++ and learn it well. You'll have no regrets.


    PS: And I agree with Prelude in most instances realting to OOP. The more I dive into C++ the more I find myself resorting to using very little inheritance. Don't get me wrong C++ is great but OOPing everything in sight only leads to mass confusion, slow code, and a bewildered programmer.
    Last edited by VirtualAce; 06-11-2004 at 08:31 PM.

  12. #12
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    I am currently trying to learn c++ right now and I wonder if its worth all the trouble. I think it has a lot of features that when mastered could make programming easier but the problem is its a huge, complex language thats difficult to master. And something that annoys me is that most compilers don't fully implement the language. I am working on a program that compiles with gcc but not with vc7 or borland c++. The only reason im learning c++ is because its one of the most widely used languages and there's a lot of c++ code available on the net that I would like to be able to understand so that I can use it with my language of preference.
    Last edited by silk.odyssey; 06-12-2004 at 09:58 AM.
    silk.odyssey

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Good Programming schools are they out there???
    By jbarby in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-12-2009, 06:31 PM
  2. Good pointer learning tool?
    By Devolution in forum C Programming
    Replies: 12
    Last Post: 03-12-2009, 05:26 AM
  3. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-30-2009, 02:34 PM
  4. Learning C++ resources
    By uriel2013 in forum C++ Programming
    Replies: 4
    Last Post: 04-26-2003, 09:30 PM
  5. Any Good websites for learning MSVC++? - NT
    By kamikazeecows in forum Windows Programming
    Replies: 4
    Last Post: 12-10-2001, 07:02 AM