Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. Why do some people prefer C over C++?

Why do some people prefer C over C++?

Scheduled Pinned Locked Moved The Lounge
c++hardwarequestion
61 Posts 20 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Code2326

    I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

    E Offline
    E Offline
    El Corazon
    wrote on last edited by
    #12

    Code2326 wrote:

    I was told C could do more than C++

    Neither can do more than the other. Any class can be written in C, but the difference is ease of organization and definition of structure. Just as patterns define common operations, classes provided the first standard for organization of programming methodology for C, thus C plus plus, being C plus more. Given that there was no standard for organizational structure libraries were often disjointed, having no coherent "glue" to hold them together. C++ is not inherently slower, but some operations are inherently slower, so knowledge is best. For instance, never using a virtual method for a commonly called routine in a program that needs speed. Minimizing nesting of inheritance, as well as classes with classes as members. Nesting is an important part of organizational structure, but just as writing API functions that call smaller API functions which called smaller API functions, which called smaller API functions, you can easily go to far. Your brain is the best optimization/organization tool, used correctly with C/C++ both are fast. C++ has then the organizational coherence of a standard method and storage containers. No more writing a linked list, though I miss a skip-list.... No more organization of routines wth functon pointers, classes provdide an easier to maintain standard. if you write a class using all virtual functions and deep inheritance and circular inheritance you can prove that C++ is slower... but since this is poor practices in the first place, all you are doing is proving why it s a poor practice, nothing about the language itself. You can just as easily build an API with nested calls, deep recursion, and no more than 2 lines of code in every function, the resulting stack calls will eat all your performance. Everything has a cost, knowing that cost is the first step to programming for performance. Balancing that performance cost and development/organization cost is something that comes with experience. We have constant arguments here, that organizaton should outweigh performance in all cases. I disagree, I believe they are both important. C++ is neither a miracle, nor a curse, it is a technological advancement of the language of C for multiple reasons. If you know and understand those reasons you have an extra tool in your brain for application of C++ structures.

    _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about t

    1 Reply Last reply
    0
    • L leckey 0

      I've noticed that whichever one learns first, seems to be the preference. What about C++ bothers you the most?

      _____________________________________________ Flea Market! It's just like...it's just like...A MINI-MALL!

      E Offline
      E Offline
      El Corazon
      wrote on last edited by
      #13

      leckey wrote:

      I've noticed that whichever one learns first, seems to be the preference.

      Although that is the majority of human nature, it still is not always true. :) Basic->Fortran->Pascal->(first attempt at C)->S-Basic->Cobol->RPG-II->Modula->LISP->Prolog->Forth->C->Assembly->Ada->C*->C++->C# I am sure I left out a few in there, but I still prefer C++.

      _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

      1 Reply Last reply
      0
      • C Christian Graus

        It *is* simpler, as C++ adds to C. It is cleaner, if you don't understand OO. It's not easier to learn, no way. Only if C++ is taught *wrong* is it easier to learn C.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        C Offline
        C Offline
        Chris Austin
        wrote on last edited by
        #14

        Christian Graus wrote:

        Only if C++ is taught *wrong* is it easier to learn C.

        I would agree with you here. I think a lot of people approach C++ as being "just" C with OOP starting out.

        My Blog A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. - -Lazarus Long

        C 1 Reply Last reply
        0
        • C Code2326

          I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

          N Offline
          N Offline
          Nirosh
          wrote on last edited by
          #15

          They are afraid of/ don't like the change. Just like those people who use the same pen continuously for quite a long time, and even after it is over, still want to keep the old one aside with the new one.

          L.W.C. Nirosh. Colombo, Sri Lanka.

          1 Reply Last reply
          0
          • L leckey 0

            I've noticed that whichever one learns first, seems to be the preference. What about C++ bothers you the most?

            _____________________________________________ Flea Market! It's just like...it's just like...A MINI-MALL!

            J Offline
            J Offline
            James Brown
            wrote on last edited by
            #16

            I actually like C++ quite a lot, sometimes very nice code can be written in it and it lends itself very well to many types of program. It is just the 'gotcha's that put me off, and some of the language features that can make code utterly unreadable, templates being the main offender. Also the many implicit behaviours and side-effects that can be introduced by the most innocent of statement.


            http://www.catch22.net

            E 1 Reply Last reply
            0
            • C Code2326

              I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

              J Offline
              J Offline
              Josh Smith
              wrote on last edited by
              #17

              Because they have never tried C#. ;P :josh puts on fireproof body suit:

              :josh: My WPF Blog[^] The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it. - Michelangelo (1475-1564)

              E 1 Reply Last reply
              0
              • C Christian Graus

                It *is* simpler, as C++ adds to C. It is cleaner, if you don't understand OO. It's not easier to learn, no way. Only if C++ is taught *wrong* is it easier to learn C.

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                J Offline
                J Offline
                James Brown
                wrote on last edited by
                #18

                not true, C will always be easier to learn because it is such a simple language. C++ is a huge language, far more powerful and expressive than C and subsequently takes alot more time to learn the nuances of the language. OO vs non-OO and the different approaches required for each never formed a part in my argument.


                http://www.catch22.net

                C E 2 Replies Last reply
                0
                • C Code2326

                  I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

                  G Offline
                  G Offline
                  Gary R Wheeler
                  wrote on last edited by
                  #19

                  C is much simpler to learn. No object-oriented stuff, operator overloading, exceptions, etc. C++ offers vastly better facilities for software engineering a project. Namespaces, classes, etc. If you've ever maintained a 250,000 line code base in C (which I have), you'll understand. C and C++ are equally 'close' to the hardware. There are certain programming idioms that are more succinctly expressed in C++ than in C. There is no inherent performance disadvantage to C++ for many applications. Most things cited for this bit of FUD (exception handling, for example) are controllable with compiler options. If you don't use that feature, turn it off and its effect on performance is eliminated. Truth be told, I would not be surprised to find some C++ programs that are significantly faster than the corresponding C code, simply due to the fact that the compiler implements certain programming techniques in machine code in C++ that you would have to construct 'by hand' in C. I spent six years doing pure C development. I've spent the last ten years doing C++ work. Given a choice, I will always choose C++ over C.


                  Software Zen: delete this;

                  Fold With Us![^]

                  1 Reply Last reply
                  0
                  • C Code2326

                    I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

                    M Offline
                    M Offline
                    Marc Clifton
                    wrote on last edited by
                    #20

                    Because they're stupid. Marc

                    Thyme In The Country
                    Interacx
                    My Blog

                    J G M 3 Replies Last reply
                    0
                    • M Marc Clifton

                      Because they're stupid. Marc

                      Thyme In The Country
                      Interacx
                      My Blog

                      J Offline
                      J Offline
                      Josh Smith
                      wrote on last edited by
                      #21

                      Marc Clifton wrote:

                      Because they're stupid.

                      :laugh: Wow, I didn't see that one coming!

                      :josh: My WPF Blog[^] The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it. - Michelangelo (1475-1564)

                      1 Reply Last reply
                      0
                      • C Chris Austin

                        Christian Graus wrote:

                        Only if C++ is taught *wrong* is it easier to learn C.

                        I would agree with you here. I think a lot of people approach C++ as being "just" C with OOP starting out.

                        My Blog A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. - -Lazarus Long

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #22

                        Chris Austin wrote:

                        I think a lot of people approach C++ as being "just" C with OOP starting out.

                        Yeah, a lot of professors are old C programmers, who teach C with classes. That just makes it hard.

                        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                        1 Reply Last reply
                        0
                        • J James Brown

                          not true, C will always be easier to learn because it is such a simple language. C++ is a huge language, far more powerful and expressive than C and subsequently takes alot more time to learn the nuances of the language. OO vs non-OO and the different approaches required for each never formed a part in my argument.


                          http://www.catch22.net

                          C Offline
                          C Offline
                          Christian Graus
                          wrote on last edited by
                          #23

                          But, you can teach C++ by starting with the part that is C. That's totally the wrong way to teach it, and teaching it right makes C++ easier than C, IMO. Teaching C++ doesn't have to mean teaching the whole language, just enough to get people started. Then they can move on to templates, STL containers, iostreams, etc, once they have a firm grounding. C is easier because it's simpler, only if you assume that 'learn' means 'know every facet of the language'. As your comment above shows, many people use C++ and never learn how templates work, for example.

                          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                          E J 2 Replies Last reply
                          0
                          • C Code2326

                            I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

                            M Offline
                            M Offline
                            martin_hughes
                            wrote on last edited by
                            #24

                            I really hate arguments about languages - it's all so thoroughly pointless as no one ever wins, and the arguments go on. And on. And on. If any of it really mattered, we'd all still be writing in machine code, or better yet we'd still be calculating stuff on an abacus. C or C++? Who cares? Use whatever you want to use (even VB6 if the feel takes you!), invent your own language if you like - just remember: your end user won't care one jot what language your programs are written in, all they want to know is a)does it do what they want, and b)how long it took you to deliver them.

                            "It was the day before today.... I remember it like it was yesterday." -Moleman

                            1 Reply Last reply
                            0
                            • J James Brown

                              not true, C will always be easier to learn because it is such a simple language. C++ is a huge language, far more powerful and expressive than C and subsequently takes alot more time to learn the nuances of the language. OO vs non-OO and the different approaches required for each never formed a part in my argument.


                              http://www.catch22.net

                              E Offline
                              E Offline
                              El Corazon
                              wrote on last edited by
                              #25

                              James Brown wrote:

                              not true, C will always be easier to learn because it is such a simple language

                              not true, because eventually you must follow on with storage mechanisms, pointers, pointers to functions, lists, trees, etc. Now you have added more complexity to C to keep up with the capability of C++, and have done it in inconsistant methodologies such that one C programmer has difficult understanding what another did -- and no consistency of performance, one list implimentation is not the same as another. Of course you could say, as long as no one writes anything complex, C is always the winner. Well :doh: I can write a hello world program in ASM more compact too, that doesn't mean it is the right tool for all jobs.

                              _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                              J 1 Reply Last reply
                              0
                              • M Marc Clifton

                                Because they're stupid. Marc

                                Thyme In The Country
                                Interacx
                                My Blog

                                G Offline
                                G Offline
                                Gary R Wheeler
                                wrote on last edited by
                                #26

                                Go right ahead, make me feel like a pompous wind-bag :laugh:. Your answer is far more to the point.


                                Software Zen: delete this;

                                Fold With Us![^]

                                E 1 Reply Last reply
                                0
                                • G Gary R Wheeler

                                  Go right ahead, make me feel like a pompous wind-bag :laugh:. Your answer is far more to the point.


                                  Software Zen: delete this;

                                  Fold With Us![^]

                                  E Offline
                                  E Offline
                                  El Corazon
                                  wrote on last edited by
                                  #27

                                  Gary R. Wheeler wrote:

                                  Go right ahead, make me feel like a pompous wind-bag

                                  my posts were twice the size of yours... if he makes you a pompous wind-bag, what extreme does that make me????

                                  _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                  E 1 Reply Last reply
                                  0
                                  • C Code2326

                                    I was told C could do more than C++ even though C++ is the "evolution" of C. In the sense that I'm programming with robots such as those in FIRST, I was also told that C is "closer" to the hardware. Are all of those true? Mind if someone tell me why he/she prefer C over C++? I'm so confused and lost. :confused:

                                    C Offline
                                    C Offline
                                    cp9876
                                    wrote on last edited by
                                    #28

                                    Because they don't want to use object oriented design. My experience in complex projects is that C++ used well results in great code, as fast as C, developed in less time and is far easier to maintain. C++ is also much more fun than C - even when producing great code. Having to develop everything in C is a nightmare scenario! However, developing the skills to use C++ well takes much longer than learning to use C, and I have seen some people who I believe will never make good OO designers. I have seen people with poor C++ skills produce code that is much more obscure than C, is much slower and almost impossible to maintain. It would have been almost impossible to write programs that badly in C, simply because C++ gave them more features to misuse. C++ is a fantastic tool in the hands of a skilled craftsman.


                                    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

                                    1 Reply Last reply
                                    0
                                    • J Josh Smith

                                      Because they have never tried C#. ;P :josh puts on fireproof body suit:

                                      :josh: My WPF Blog[^] The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it. - Michelangelo (1475-1564)

                                      E Offline
                                      E Offline
                                      El Corazon
                                      wrote on last edited by
                                      #29

                                      Josh Smith wrote:

                                      Because they have never tried C#. :josh puts on fireproof body suit:

                                      you should have reversed the order there.... ;P If someone had been faster, they could have got you good.... ;P

                                      _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                      J 1 Reply Last reply
                                      0
                                      • E El Corazon

                                        James Brown wrote:

                                        not true, C will always be easier to learn because it is such a simple language

                                        not true, because eventually you must follow on with storage mechanisms, pointers, pointers to functions, lists, trees, etc. Now you have added more complexity to C to keep up with the capability of C++, and have done it in inconsistant methodologies such that one C programmer has difficult understanding what another did -- and no consistency of performance, one list implimentation is not the same as another. Of course you could say, as long as no one writes anything complex, C is always the winner. Well :doh: I can write a hello world program in ASM more compact too, that doesn't mean it is the right tool for all jobs.

                                        _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                        J Offline
                                        J Offline
                                        James Brown
                                        wrote on last edited by
                                        #30

                                        sorry sunshine, but no matter what way you look at things, C is a simpler language and is therefore easier to learn. libraries/data structures are irrelevant and never formed a part of my argument.


                                        http://www.catch22.net

                                        E 1 Reply Last reply
                                        0
                                        • C Christian Graus

                                          But, you can teach C++ by starting with the part that is C. That's totally the wrong way to teach it, and teaching it right makes C++ easier than C, IMO. Teaching C++ doesn't have to mean teaching the whole language, just enough to get people started. Then they can move on to templates, STL containers, iostreams, etc, once they have a firm grounding. C is easier because it's simpler, only if you assume that 'learn' means 'know every facet of the language'. As your comment above shows, many people use C++ and never learn how templates work, for example.

                                          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                                          E Offline
                                          E Offline
                                          El Corazon
                                          wrote on last edited by
                                          #31

                                          Christian Graus wrote:

                                          "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax"

                                          I just read this.... :doh::doh::omg: That's like seeing... "I am starting a project in 3D graphics for a game... what is 3D graphics?" :doh:

                                          _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups