Thread: Biggest advantages of C++ over C and vice versa

  1. #1
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    200

    Biggest advantages of C++ over C and vice versa

    Hello, I would like to hear from you, what is in your opinion is the biggest strength of C++ over C and vice versa.

    Do you appreciate OO in C++ ? Or something else more push you to use C++ instead of C ?

    Is it possible to imlement OO in C making another function or sub program which can produce OO and let us use inheritance, encapsulation and other features of object orientation ?


    Regards.

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    All of these question has been asked and answered a million times, and you'll find a billion related opinions.

    Really now, what do we have? Is this "trollbait"? Or is this "I didn't want to take two seconds to search the web."?

    [Edit]
    ib4grumpy
    [/Edit]

    [Edit]
    Defending the thread with "I wanted to know specifically about the regulars." is pointless.

    Search the forum; you'll find that all the regulars have already expressed their opinions.
    [/Edit]

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  3. #3
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    200
    Quote Originally Posted by phantomotap View Post
    O_o

    All of these question has been asked and answered a million times, and you'll find a billion related opinions.
    Sure, questions like C or C++ or which one is better for particular job have been discussed a hundreds times, but my question is little bit more deep. I would like to hear from user for makes them to use C++ or C.
    Plus what is even more important, I want to discuss about posibilities of implemnting OO mechanism into C.

    Where you see similar subjects ?

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Where you see similar subjects ?
    O_o

    I wonder...

    Soma
    Attached Images Attached Images Biggest advantages of C++ over C and vice versa-where-png 
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by MartinR View Post
    I would like to hear from user for makes them to use C++ or C.
    Okay, C++ user here. For me, the advantage of C++ is that, if coded to certain standards, it can provide type and memory safety and code correctness that C simply can't, and it can do so while meeting or exceeding C performance. I've had this debate here before and it triggered a flame war, so I'll leave it there. But that's the perspective of one real-world C++ user (by user I mean I write commercial software in C++).

    Plus what is even more important, I want to discuss about posibilities of implemnting OO mechanism into C.
    Implementing C++-like method calling in C is an interesting homework problem but makes for a trivial discussion topic. It can be done, and in several different ways.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Registered User
    Join Date
    Mar 2011
    Posts
    596
    Look for "Object-oriented Programming with ANSI-C" - Axel-Tobias Schreiner

    It's quite comprehensive, 221 pages, and may be still available as a free download.

    -

  7. #7
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by MartinR View Post
    Hello, I would like to hear from you, what is in your opinion is the biggest strength of C++ over C and vice versa.
    Ctors/dtors, RAII, and exceptions.


    Quote Originally Posted by MartinR View Post
    Do you appreciate OO in C++ ? Or something else more push you to use C++ instead of C ?
    C++'s biggest strength I think, is that you can *almost* use it with the ease of a garbage collected language, even though it's not actually garbage collected.


    Quote Originally Posted by MartinR View Post
    Is it possible to imlement OO in C making another function or sub program which can produce OO and let us use inheritance, encapsulation and other features of object orientation ?
    Why? Use C++ if you want that. And use composition over inheritance when possible.

  8. #8
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    200
    Quote Originally Posted by Yarin View Post
    C++'s biggest strength I think, is that you can *almost* use it with the ease of a garbage collected language, even though it's not actually garbage collected.
    Thanks for your opinion, could you expand it a little bit ? What you mean by "garbage collected language" ?

  9. #9
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    What he means is, the STL is BOSS! And smart pointers are nice too.

    What I personally love about C++ has been mentioned by Yarin (constructors, RAII and exceptions) but the STL is a huge part for me. Clever use of the STL allows you to program quite a bit.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MartinR View Post
    Thanks for your opinion, could you expand it a little bit ? What you mean by "garbage collected language" ?
    A language that uses garbage collection instead of manual freeing of resources. Examples include Java, C#, PHP, Javascript, VB, etc. Well, pretty much any modern language save for C and C++ are garbage collected.
    C++ does it differently by giving you control over where memory is freed (typically via smart pointers). It can either be when a function ends or through reference counting (i.e. counting the number of pointers existing to an object and destroying it when the last pointer to the resource is destroyed).
    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
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    200
    Thanks for your opinions guys

    So far I have done some work in both C and C++, what I see is C++ allows programmers to write programs faster and easier plus has a lot useful features which C lack.
    When you ask people about both languages they tends to think about C++ as a more modern language which should be considered in 90 % of work.

    So here is my question, why C was chose as a base of most OS, programming languages (i.e perl,python) , software and so on.
    Basically why this small language with only 32 keywords and almost 50 years history is still so popular and chosen to so many tasks ?

  12. #12
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    200
    testing...

  13. #13
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    It's because C++ is a horrible, horrible language : Gmane Loom

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MartinR View Post
    Thanks for your opinions guys

    So far I have done some work in both C and C++, what I see is C++ allows programmers to write programs faster and easier plus has a lot useful features which C lack.
    When you ask people about both languages they tends to think about C++ as a more modern language which should be considered in 90 % of work.

    So here is my question, why C was chose as a base of most OS, programming languages (i.e perl,python) , software and so on.
    Basically why this small language with only 32 keywords and almost 50 years history is still so popular and chosen to so many tasks ?
    A lot of operating systems and programming languages were invented before C++ existed, and some people just dislike C++. Yes, the fabled language wars!
    For others, it's simply legacy code, lack of C++ programmers, poor toolchains. Also, many C++ features, such as exceptions. just don't work well with operating systems. But I do fear that there is a general bias that C++ cannot be used for operating systems (which is false). It's just another of those things people tell themselves.
    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.

  15. #15
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by MartinR View Post
    So here is my question, why C was chose as a base of most OS, programming languages (i.e perl,python) , software and so on.
    Basically why this small language with only 32 keywords and almost 50 years history is still so popular and chosen to so many tasks ?
    This tastes like bait, but I'll bite.
    It's tantamount to heresy to say this on these forums, but... C is still preferable to C++ in some low-level applications. (For example, exceptions, great as they are, are a horrible thing to implement in very low level environments.)


    Quote Originally Posted by MutantJohn View Post
    It's because C++ is a horrible, horrible language
    Yes, C++ is so horrible. You want a language that gives you manual memory control and RAII? F**k you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resistor value to color code and vice versa
    By Eddie Ramos in forum C++ Programming
    Replies: 15
    Last Post: 09-30-2012, 09:49 AM
  2. Chaning AM to PM and vice versa
    By EssiJoon in forum C Programming
    Replies: 2
    Last Post: 04-19-2012, 09:36 PM
  3. int to char and vice versa
    By mekaj in forum C++ Programming
    Replies: 13
    Last Post: 12-12-2005, 11:35 AM
  4. Problem: far to near copy, and vice versa
    By aaronc in forum C Programming
    Replies: 1
    Last Post: 06-16-2004, 06:37 AM
  5. Binary to ascii and vice versa
    By thenrkst in forum C++ Programming
    Replies: 13
    Last Post: 03-30-2003, 01:17 AM