C or C++?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • weidongtom@gmail.com

    C or C++?

    Hi,

    I am a newbie to programming, and sorry again that I have to ask the C
    or C++ questions. Is C required before learning C++? And become better
    in C does it also make you a better C++ programmer? Or that to be a C+
    + programmer, it's better not to have any knowledge of C and start a
    new in the C++ way as some books suggest?

  • red floyd

    #2
    Re: C or C++?

    weidongtom@gmai l.com wrote:
    Hi,
    >
    I am a newbie to programming, and sorry again that I have to ask the C
    or C++ questions. Is C required before learning C++?
    No.

    And become better
    in C does it also make you a better C++ programmer?
    Not necessarily. Sometimes you have to "unlearn" some C ways of thinking.

    Or that to be a C+
    + programmer, it's better not to have any knowledge of C and start a
    new in the C++ way as some books suggest?
    Again, not necessarily. C and C++ are two separate languages, much as
    many people want to confuse them. However, if you know C++, I suspect
    it's easier to learn C (since it's a not-quite-perfect subset of C++).

    Comment

    • Salt_Peter

      #3
      Re: C or C++?

      On May 11, 11:55 pm, "weidong...@gma il.com" <weidong...@gma il.com>
      wrote:
      Hi,
      >
      I am a newbie to programming, and sorry again that I have to ask the C
      or C++ questions. Is C required before learning C++? And become better
      in C does it also make you a better C++ programmer? Or that to be a C+
      + programmer, it's better not to have any knowledge of C and start a
      new in the C++ way as some books suggest?
      Learn C++ first, C is not required to understand C++.
      In many cases, learning C first is a detriment.

      [28.2] Should I learn C before I learn OO/C++?


      book: Accelerated C++
      [28.7] What are some best-of-breed C++ programming-by-example guides?

      Comment

      • Branimir Maksimovic

        #4
        Re: C or C++?

        On May 12, 5:55 am, "weidong...@gma il.com" <weidong...@gma il.com>
        wrote:
        Hi,
        >
        I am a newbie to programming, and sorry again that I have to ask the C
        or C++ questions. Is C required before learning C++?
        No.

        And become better
        in C does it also make you a better C++ programmer?
        No.

        Or that to be a C+
        + programmer, it's better not to have any knowledge of C and start a
        new in the C++ way as some books suggest?
        Yes.

        I have to comment that it is common misconception that C
        is required to learn C++ as C++ is based on C.
        You can just adopt bad habits from C ;) It is easier
        to peek language and work either in C or C++.
        C is little bit more then portable assembler and that's
        where it is it's power.
        But, in order to understand how things work you will
        need to learn at least one assembler first.
        If you learn assembler beside C++ you can use it in
        combination with it , and then you can fully understand C
        part of C++.
        Rhetorical question:
        Why is nobody asking about learning assembler, then C ?:)
        It makes much more sense.

        Greetings, Branimir.




        Comment

        • Default User

          #5
          Re: C or C++?

          Branimir Maksimovic wrote:
          On May 12, 5:55 am, "weidong...@gma il.com" <weidong...@gma il.com>
          wrote:
          Hi,

          I am a newbie to programming, and sorry again that I have to ask
          the C or C++ questions. Is C required before learning C++?
          I have to comment that it is common misconception that C
          is required to learn C++ as C++ is based on C.
          It's also a common misconception that C is a hindrance.
          You can just adopt bad habits from C ;)
          You can learn bad habits in any language.
          C is little bit more then portable assembler and that's
          where it is it's power.
          This comment indicates that you really know nothing of the C language,
          and are just parroting back things others have told you.

          C is not in any way shape or form an assembler, portable or otherwise.




          Brian

          Comment

          • Bo Persson

            #6
            Re: C or C++?

            Default User wrote:
            :: Branimir Maksimovic wrote:
            ::
            ::: On May 12, 5:55 am, "weidong...@gma il.com" <weidong...@gma il.com>
            ::: wrote:
            :::: Hi,
            ::::
            :::: I am a newbie to programming, and sorry again that I have to ask
            :::: the C or C++ questions. Is C required before learning C++?
            ::
            ::: I have to comment that it is common misconception that C
            ::: is required to learn C++ as C++ is based on C.
            ::
            :: It's also a common misconception that C is a hindrance.
            ::
            ::: You can just adopt bad habits from C ;)
            ::
            :: You can learn bad habits in any language.
            ::

            But after learning about malloc(), C string handling, casting, printf, and
            using pointers to simulate pass by reference, you have a lot to unlearn. If
            you want to learn C++, do that!


            Bo Persson


            Comment

            • Branimir Maksimovic

              #7
              Re: C or C++?

              On May 12, 9:31 am, "Default User" <defaultuse...@ yahoo.comwrote:
              Branimir Maksimovic wrote:
              On May 12, 5:55 am, "weidong...@gma il.com" <weidong...@gma il.com>
              wrote:
              Hi,
              >
              I am a newbie to programming, and sorry again that I have to ask
              the C or C++ questions. Is C required before learning C++?
              I have to comment that it is common misconception that C
              is required to learn C++ as C++ is based on C.
              >
              It's also a common misconception that C is a hindrance.
              I don;t think so. C community is large and this language is main
              tool in it's area.
              >
              You can just adopt bad habits from C ;)
              >
              You can learn bad habits in any language.
              Well, I am joking here .
              >
              C is little bit more then portable assembler and that's
              where it is it's power.
              >
              This comment indicates that you really know nothing of the C language,
              and are just parroting back things others have told you.
              >
              C is not in any way shape or form an assembler, portable or otherwise.
              Look, I have learned assembler first, then C.
              Things like address of , dereference, pre and post increment/
              decrement
              operators, C arrays/strings and pointer arithmetic came from assembler
              style programming and instruction sets obviously.
              I had 17 years when first met C, with previous assembler experience,
              I immediately recognized what this language is all about
              and felt like home.
              Only difference is that C has strict type system, structures,
              parameter passing / cleanup is done automatically
              and language has higher level constructs like if/switch/for/while ....
              But then again any modern assembler have advanced features ,
              even support for OO programming ;)
              So real question is what can be done with assembly ,
              that can't be done with C. In practice, except direct access to
              hardware features that are unavailable to language due portability
              issues, there are no real differences.
              Other question is how C maps to machine code.
              If you look at generated code it maps pretty close.
              So in theory, yes , C can be very far from real hardware,
              but always very close to it's abstract machine which
              is in reality pretty close model to real machine
              or, if not, (remember dos days?)
              there are always non standard extensions to bring it closer;)

              Greetings, Branimir.


              Comment

              • Roland Pibinger

                #8
                Re: C or C++?

                On 11 May 2007 20:55:29 -0700, "weidongtom@gma il.com" wrote:
                >I am a newbie to programming, and sorry again that I have to ask the C
                >or C++ questions.
                Why would you want to learn C++ today?
                >Is C required before learning C++?
                No in theory, yes in practice. C++ is an extension of C done in
                several evolutionary steps. If you don't know the roots of the
                language it just appears weird to you.
                >And become better
                >in C does it also make you a better C++ programmer?
                Certainly. Many basic programming concepts are the same. Some C++
                libraries, e.g. STL, are directly derived from C.
                >Or that to be a C+
                >+ programmer, it's better not to have any knowledge of C and start a
                >new in the C++ way as some books suggest?
                This point of view was propagated for some time and it probably left
                many students in confusion.


                --
                Roland Pibinger
                "The best software is simple, elegant, and full of drama" - Grady Booch

                Comment

                • =?ISO-8859-1?Q?Erik_Wikstr=F6m?=

                  #9
                  Re: C or C++?

                  On 2007-05-12 11:25, Roland Pibinger wrote:
                  On 11 May 2007 20:55:29 -0700, "weidongtom@gma il.com" wrote:
                  >>I am a newbie to programming, and sorry again that I have to ask the C
                  >>or C++ questions.
                  >
                  Why would you want to learn C++ today?
                  Why not, it's still one of the most commonly used languages out there
                  and it's also one of the more advanced ones. I claim that anything you
                  learn while working with C++ can be of use in other languages as well,
                  the reverse however is not always true since some other languages are
                  simplified (to allow faster learning) which makes some constructs
                  impossible.
                  >>Is C required before learning C++?
                  >
                  No in theory, yes in practice. C++ is an extension of C done in
                  several evolutionary steps. If you don't know the roots of the
                  language it just appears weird to you.
                  Most (I among them) would probably disagree with that statement,
                  knowledge of C is in no way necessary to learn C++, however if you want
                  to learn how to use "all" of the C++ language you'll sooner or later
                  come in contact with the C heritage of C++ and thus will learn how to
                  program in C also.

                  The roots of modern C++ (which is mostly concerned with OO and generic
                  programming and less with procedural programming) are not in C, but
                  rather Simula and I doubt that you'll recommend the OP to learn that,
                  will you?
                  >And become better in C does it also make you a better C++
                  >programmer?
                  >
                  Certainly. Many basic programming concepts are the same. Some C++
                  libraries, e.g. STL, are directly derived from C.
                  I'd say perhaps, that depends on which parts of C++ you'll be using, if
                  you focus on the OO parts you'll have less use of what you learned from
                  C, if you want to use C++ as C with classes then you'll have more use of it.
                  >Or that to be a C++ programmer, it's better not to have any
                  >knowledge of C and start a new in the C++ way as some books
                  >suggest?
                  >
                  This point of view was propagated for some time and it probably left
                  many students in confusion.
                  The reason is simple, old habits die hard, and by learning to program in
                  C first you'll learn a certain "style", certain ways to do thing and
                  organizing your code, store data and so on. The problem is that C is a
                  procedural language while C++ is a multi-paradigm language supporting
                  procedural, object-oriented and generic programming, and all of these
                  paradigms leads to different "styles". If you learn C first it might be
                  harder to learn the "styles" needed to efficiently use the other
                  paradigms and to make the most use of C++ is to use a mix of them.

                  --
                  Erik Wikström

                  Comment

                  • Ian Collins

                    #10
                    Re: C or C++?

                    Roland Pibinger wrote:
                    On 11 May 2007 20:55:29 -0700, "weidongtom@gma il.com" wrote:
                    >And become better
                    >in C does it also make you a better C++ programmer?
                    >
                    Certainly. Many basic programming concepts are the same. Some C++
                    libraries, e.g. STL, are directly derived from C.
                    >
                    Do what? How does say, std::vector derive form C? The C standard
                    library (with some modifications) is part of C++, but that part of the
                    standard library that used to be know as the STL has nothing to do with C.

                    --
                    Ian Collins.

                    Comment

                    • Juha Nieminen

                      #11
                      Re: C or C++?

                      weidongtom@gmai l.com wrote:
                      And become better
                      in C does it also make you a better C++ programmer?
                      I would say the exact opposite: The "better" you are at C, the
                      worse you are at C++.

                      Most "advanced" C programmers have learned tons of kludges to
                      circumvent the limitations of the language, and in many cases there
                      are much better and cleaner solutions in C++ for the same things.
                      The problem with C programmers who have self-taught these kludges
                      is that the more they have used them, the more difficult is to
                      unlearn them. Coding too much C also tends to develop resistance to
                      change and make you prejudiced against C++.

                      Comment

                      • Default User

                        #12
                        Re: C or C++?

                        Bo Persson wrote:
                        Default User wrote:
                        :: Branimir Maksimovic wrote:
                        ::
                        ::: On May 12, 5:55 am, "weidong...@gma il.com" <weidong...@gma il.com>
                        ::: wrote:
                        :::: Hi,
                        ::::
                        :::: I am a newbie to programming, and sorry again that I have to ask
                        :::: the C or C++ questions. Is C required before learning C++?
                        ::
                        ::: I have to comment that it is common misconception that C
                        ::: is required to learn C++ as C++ is based on C.
                        ::
                        :: It's also a common misconception that C is a hindrance.
                        ::
                        ::: You can just adopt bad habits from C ;)
                        ::
                        :: You can learn bad habits in any language.
                        ::
                        >
                        But after learning about malloc(), C string handling, casting,
                        printf, and using pointers to simulate pass by reference, you have a
                        lot to unlearn. If you want to learn C++, do that!
                        That's absolutely true, and you'll see that I never said learning C was
                        a prerequiste, or even helpful. I'm not sure. I learned C first, as did
                        many, and found it to be helpful. Others report a different experience.



                        Brian

                        Comment

                        • Default User

                          #13
                          Re: C or C++?

                          Branimir Maksimovic wrote:
                          On May 12, 9:31 am, "Default User" <defaultuse...@ yahoo.comwrote:
                          C is not in any way shape or form an assembler, portable or
                          otherwise.
                          >
                          Look, I have learned assembler first, then C.
                          Then you have little excuse for stating such bogus information. That
                          list of programming language features is no evidence of C being a
                          "portable assembler".




                          Brian



                          Comment

                          • Default User

                            #14
                            Re: C or C++?

                            Juha Nieminen wrote:
                            weidongtom@gmai l.com wrote:
                            And become better
                            in C does it also make you a better C++ programmer?
                            >
                            I would say the exact opposite: The "better" you are at C, the
                            worse you are at C++.
                            >
                            Most "advanced" C programmers have learned tons of kludges to
                            circumvent the limitations of the language, and in many cases there
                            are much better and cleaner solutions in C++ for the same things.
                            The problem with C programmers who have self-taught these kludges
                            is that the more they have used them, the more difficult is to
                            unlearn them. Coding too much C also tends to develop resistance to
                            change and make you prejudiced against C++.
                            What a load of crap. Seriously. Most C programmers I know are flexible
                            and knowledgable in multiple languages.




                            Brian

                            Comment

                            • Roland Pibinger

                              #15
                              Re: C or C++?

                              On Sat, 12 May 2007 10:35:48 GMT, <Erik-wikstrom@...com wrote:
                              >The reason is simple, old habits die hard, and by learning to program in
                              >C first you'll learn a certain "style", certain ways to do thing and
                              >organizing your code, store data and so on. The problem is that C is a
                              >procedural language while C++ is a multi-paradigm language supporting
                              >procedural, object-oriented and generic programming, and all of these
                              >paradigms leads to different "styles". If you learn C first it might be
                              >harder to learn the "styles" needed to efficiently use the other
                              >paradigms and to make the most use of C++ is to use a mix of them.
                              IMO, that's the "you can't teach old dogs new tricks" myth that is
                              employed when a new technology isn't adopted by the real world as
                              expected. We saw it with OOP ("nobody can learn OOP who has been
                              contaminated with procedural programming") and later - under different
                              circumstances - with STL or "generic" programming ("nobody can learn
                              STL who has been contaminated with procedural or OO programming").
                              It's just a myth.



                              --
                              Roland Pibinger
                              "The best software is simple, elegant, and full of drama" - Grady Booch

                              Comment

                              Working...