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.
  • J James Brown

    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 Offline
    E Offline
    El Corazon
    wrote on last edited by
    #35

    James Brown wrote:

    Also the many implicit behaviours and side-effects that can be introduced by the most innocent of statement.

    the same can be said of pointers and defines, etc, which are a part of C. In fact templates suffer the same issues of writing with defines, only offer some design refinements. Classes are a pointer table of methods which can be written in C, but with greater risk. You can make C completely unreadable too, but it doesn't prove C is evil, it only tells about the programmer. Not knowing C++, of course it would make it unreadable, but knowing C++ well makes it very readable and much more stable.

    _________________________ 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
    • 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 )

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

      Your suggestions that C++ can be taught wrongly, although valid, has no relevance to the point being argued that I can see - C and C++ are different beasts and should be taught in isolation of each other, you will of course agree with this. And I made no comment that people use C++ and never learn templates. Are you implying that *I* am in that category? 'Know every facet'.....hmmm well, semantic arguments will lead nowhere. How about 'learn 10% of each language'? The simple fact remains, C is a simpler language than C++, it is far smaller and is easier to learn because of this.


      http://www.catch22.net

      C 1 Reply Last reply
      0
      • E El Corazon

        James Brown wrote:

        libraries/data structures are irrelevant and never formed a part of my argument

        But they are an integral part of WRITING code. Learning the language is only the first step. You are implying that as long as no one ever writes in C, C is always easier to learn. Well... true, but irrelevant, since eventually someone MUST write in it.

        _________________________ 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
        #37

        El Corazon wrote:

        You are implying that as long as no one ever writes in C, C is always easier to learn. Well... true, but irrelevant, since eventually someone MUST write in it

        No, I implied nothing of the sort. get over it.


        http://www.catch22.net

        E 1 Reply Last reply
        0
        • E El Corazon

          James Brown wrote:

          Also the many implicit behaviours and side-effects that can be introduced by the most innocent of statement.

          the same can be said of pointers and defines, etc, which are a part of C. In fact templates suffer the same issues of writing with defines, only offer some design refinements. Classes are a pointer table of methods which can be written in C, but with greater risk. You can make C completely unreadable too, but it doesn't prove C is evil, it only tells about the programmer. Not knowing C++, of course it would make it unreadable, but knowing C++ well makes it very readable and much more stable.

          _________________________ 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
          #38

          pointers used within the constraints of the language have no side-effects, and they are also part of C++. #defines, macros, likewise.

          El Corazon wrote:

          but knowing C++ well makes it very readable and much more stable.

          This is a nonsense argument. Knowing C well also makes it very readable and much more stable. So what?


          http://www.catch22.net

          E 1 Reply Last reply
          0
          • J James Brown

            I taught myself C first of all, then was formally taught C++ at University along with all the object-oriented trappings.


            http://www.catch22.net

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #39

            James Brown wrote:

            all the object-oriented trappings

            Including Prolog and Smalltalk?

            Visit http://www.readytogiveup.com/[^] and do something special today.

            E J L 3 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:

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #40

              In industry you will often find C being used for legacy reasons or in small systems where the tools don't support C++ so well.

              Visit http://www.readytogiveup.com/[^] and do something special today.

              C 1 Reply Last reply
              0
              • E El Corazon

                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 Offline
                E Offline
                Ed Poore
                wrote on last edited by
                #41

                A pompous hot-air balloon a.k.a. a politician :shudder: :suss:


                My Blog[^]

                E 1 Reply Last reply
                0
                • J James Brown

                  Your suggestions that C++ can be taught wrongly, although valid, has no relevance to the point being argued that I can see - C and C++ are different beasts and should be taught in isolation of each other, you will of course agree with this. And I made no comment that people use C++ and never learn templates. Are you implying that *I* am in that category? 'Know every facet'.....hmmm well, semantic arguments will lead nowhere. How about 'learn 10% of each language'? The simple fact remains, C is a simpler language than C++, it is far smaller and is easier to learn because of this.


                  http://www.catch22.net

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

                  James Brown wrote:

                  C and C++ are different beasts and should be taught in isolation of each other, you will of course agree with this.

                  Yes, absolutely. The main issue with C++ is that this rarely happens, C is taught and classes are added.

                  James Brown wrote:

                  And I made no comment that people use C++ and never learn templates. Are you implying that *I* am in that category?

                  You made a comment above about templates being too confusing, I thought. If I misread, then no insult was intended, I just thought you'd already said that.

                  James Brown wrote:

                  The simple fact remains, C is a simpler language than C++, it is far smaller and is easier to learn because of this

                  The fact remains that given a *specific* task, C is no easier to learn to perform that task, it simply is less powerful and offers less options in terms of ways to approach it. If pure C code is the best way to tackle a specific problem, then you can write that code in C++. What you said is correct tho, it's what I said. C is smaller, and therefore easier to learn, only if you're talking about how long it would take to learn it completely. An example: I want a program which takes a persons name as text input, then outputs 'Hello, ' followed by the name. Which is easier to teach, memory management in C to create a char *, or iostreams code in C++ which uses the string class ?

                  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 1 Reply Last reply
                  0
                  • J James Brown

                    El Corazon wrote:

                    You are implying that as long as no one ever writes in C, C is always easier to learn. Well... true, but irrelevant, since eventually someone MUST write in it

                    No, I implied nothing of the sort. get over it.


                    http://www.catch22.net

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

                    James Brown wrote:

                    No, I implied nothing of the sort. get over it.

                    you said problems with complex programs in C are irrelevant, the primary and unrefutable reason for making C++ in the first place, is irrelevant because you only want to focus on the simplicity of the simpliest program. Data storage is irrelevant because a program will never store or use anything because you want to focus only on the simpliest usage of C, not real-world implimentation issues. libraries, complexites, only the bad behaviors you want to acknowledge are relevant, not the complexities and bad behaviors you don't want to acknowledge... well, sure, if you want to avoid the real-world coding problems, I agree wth you. So again, as long as you never have to write anything sufficiently complex or useful, never have to read anyone else's code, or store, or transmit, or exchange informaton with any routine or program. as long as you never actually do anything with your code, you are correct, C is better. But then... by the same logic, so is Assembly.

                    _________________________ 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
                    • J James Brown

                      pointers used within the constraints of the language have no side-effects, and they are also part of C++. #defines, macros, likewise.

                      El Corazon wrote:

                      but knowing C++ well makes it very readable and much more stable.

                      This is a nonsense argument. Knowing C well also makes it very readable and much more stable. So what?


                      http://www.catch22.net

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

                      James Brown wrote:

                      pointers used within the constraints of the language have no side-effects

                      similarly the structures of C++ have no side-effects when used properly. however, since C has no constraints on macros (they are simply compiler pre-processor substitution), it is very easy to have side-effects. Any C programmer of decades could probably provide you with a small book of examples.

                      _________________________ 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
                      • L Lost User

                        James Brown wrote:

                        all the object-oriented trappings

                        Including Prolog and Smalltalk?

                        Visit http://www.readytogiveup.com/[^] and do something special today.

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

                        I knew I forgot a language in my list! ... well, at least it was a small one. :laugh:

                        _________________________ 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
                        • E Ed Poore

                          A pompous hot-air balloon a.k.a. a politician :shudder: :suss:


                          My Blog[^]

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

                          Ed.Poore wrote:

                          A pompous hot-air balloon a.k.a. a politician :shudder:

                          :wtf::omg::wtf:

                          _________________________ 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
                          • E El Corazon

                            James Brown wrote:

                            pointers used within the constraints of the language have no side-effects

                            similarly the structures of C++ have no side-effects when used properly. however, since C has no constraints on macros (they are simply compiler pre-processor substitution), it is very easy to have side-effects. Any C programmer of decades could probably provide you with a small book of examples.

                            _________________________ 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
                            #47

                            similarly C++ has no constraints on macros. Structures in C++ *do* have side effects. Do you know what constructors, and destructors are? Your 'argument' makes absolutely no sense whatsoever.


                            http://www.catch22.net

                            E 1 Reply Last reply
                            0
                            • J James Brown

                              C is simpler, cleaner and easier to learn. C++ is bloated, complicated, and is a horrible hack because it must maintain backward-compatiblity with C.


                              http://www.catch22.net

                              P Offline
                              P Offline
                              Paul Conrad
                              wrote on last edited by
                              #48

                              James Brown wrote:

                              C++ is bloated, complicated, and is a horrible hack because it must maintain backward-compatiblity with C.

                              Not so.

                              "The clue train passed his station without stopping." - John Simmons / outlaw programmer

                              1 Reply Last reply
                              0
                              • L Lost User

                                James Brown wrote:

                                all the object-oriented trappings

                                Including Prolog and Smalltalk?

                                Visit http://www.readytogiveup.com/[^] and do something special today.

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

                                Yes, I did prolog for far too long - even psychiatric counselling hasn't helped me get over it :-) Smalltalk, I only studied that very briefly and have very little memory of it.


                                http://www.catch22.net

                                1 Reply Last reply
                                0
                                • C Christian Graus

                                  James Brown wrote:

                                  C and C++ are different beasts and should be taught in isolation of each other, you will of course agree with this.

                                  Yes, absolutely. The main issue with C++ is that this rarely happens, C is taught and classes are added.

                                  James Brown wrote:

                                  And I made no comment that people use C++ and never learn templates. Are you implying that *I* am in that category?

                                  You made a comment above about templates being too confusing, I thought. If I misread, then no insult was intended, I just thought you'd already said that.

                                  James Brown wrote:

                                  The simple fact remains, C is a simpler language than C++, it is far smaller and is easier to learn because of this

                                  The fact remains that given a *specific* task, C is no easier to learn to perform that task, it simply is less powerful and offers less options in terms of ways to approach it. If pure C code is the best way to tackle a specific problem, then you can write that code in C++. What you said is correct tho, it's what I said. C is smaller, and therefore easier to learn, only if you're talking about how long it would take to learn it completely. An example: I want a program which takes a persons name as text input, then outputs 'Hello, ' followed by the name. Which is easier to teach, memory management in C to create a char *, or iostreams code in C++ which uses the string class ?

                                  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
                                  #50

                                  Christian Graus wrote:

                                  The fact remains that given a *specific* task, C is no easier to learn to perform that task, it simply is less powerful and offers less options in terms of ways to approach it. If pure C code is the best way to tackle a specific problem, then you can write that code in C++.

                                  yes, I agree absolutely. I was simply stating that C is simpler to learn than C++, and quite deliberately made no further comment as to which was the better language :-) It's usually much more work to write something in C compared with C++, and for this reason I usually choose C++ (or a subset of) to write things in. Plus the type-safety and all the other good things that the C++ language offers mean that it is much more useful than C. But, it is a right b****rd to learn fully.


                                  http://www.catch22.net

                                  C 1 Reply Last reply
                                  0
                                  • J James Brown

                                    similarly C++ has no constraints on macros. Structures in C++ *do* have side effects. Do you know what constructors, and destructors are? Your 'argument' makes absolutely no sense whatsoever.


                                    http://www.catch22.net

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

                                    James Brown wrote:

                                    Do you know what constructors, and destructors are?

                                    yes, and they have no side-affects. They exist and behave exactly as the definition has them and work quite well. So you obviously don't know how they work since you are now saying they must have side-effects?

                                    _________________________ 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:

                                      No, I implied nothing of the sort. get over it.

                                      you said problems with complex programs in C are irrelevant, the primary and unrefutable reason for making C++ in the first place, is irrelevant because you only want to focus on the simplicity of the simpliest program. Data storage is irrelevant because a program will never store or use anything because you want to focus only on the simpliest usage of C, not real-world implimentation issues. libraries, complexites, only the bad behaviors you want to acknowledge are relevant, not the complexities and bad behaviors you don't want to acknowledge... well, sure, if you want to avoid the real-world coding problems, I agree wth you. So again, as long as you never have to write anything sufficiently complex or useful, never have to read anyone else's code, or store, or transmit, or exchange informaton with any routine or program. as long as you never actually do anything with your code, you are correct, C is better. But then... by the same logic, so is Assembly.

                                      _________________________ 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
                                      #52

                                      El Corazon wrote:

                                      you said problems with complex programs in C are irrelevant

                                      No, I did not. Learn to read. I *never* said that C was better, or worse than C++. You are reading huge amounts into my simple statement 'C is easier to learn' and are desperately trying to win an argument that doesn't exist, because I made no further comments as to which language was better or more useful.


                                      http://www.catch22.net

                                      1 Reply Last reply
                                      0
                                      • E El Corazon

                                        James Brown wrote:

                                        Do you know what constructors, and destructors are?

                                        yes, and they have no side-affects. They exist and behave exactly as the definition has them and work quite well. So you obviously don't know how they work since you are now saying they must have side-effects?

                                        _________________________ 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
                                        #53

                                        once again, you are making absolutely no sense. I did *not* say that constructors and desctructors have side effects. Your attempt at reasoning appears to be non-existant. I have nothing further to say to you.


                                        http://www.catch22.net

                                        1 Reply Last reply
                                        0
                                        • J James Brown

                                          Christian Graus wrote:

                                          The fact remains that given a *specific* task, C is no easier to learn to perform that task, it simply is less powerful and offers less options in terms of ways to approach it. If pure C code is the best way to tackle a specific problem, then you can write that code in C++.

                                          yes, I agree absolutely. I was simply stating that C is simpler to learn than C++, and quite deliberately made no further comment as to which was the better language :-) It's usually much more work to write something in C compared with C++, and for this reason I usually choose C++ (or a subset of) to write things in. Plus the type-safety and all the other good things that the C++ language offers mean that it is much more useful than C. But, it is a right b****rd to learn fully.


                                          http://www.catch22.net

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

                                          OK - this I agree with 100%. I guess we were trying to say the same things, or at least things that were not opposed :-)

                                          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 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