C++ vs C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • natush

    #1

    C++ vs C

    Hello,
    I'm writing an embedded application and I'm trying to decide whether to
    do it in C or C++. Does anyone know where I can find some statistic
    data comparing the two languages (size and performance)?

    Thanks,
    Nataly

  • Andrea Sini

    #2
    Re: C++ vs C

    natush wrote:[color=blue]
    > Hello,
    > I'm writing an embedded application and I'm trying to decide whether to
    > do it in C or C++. Does anyone know where I can find some statistic
    > data comparing the two languages (size and performance)?
    >
    > Thanks,
    > Nataly[/color]

    Hi Nataly,

    I don't think that you can make a comparison between the two languages
    (in term of size or performance). Generally speaking they're both usable.

    Perhaps you should take into account the performance you can get with
    the compiler you're going to use.

    Anyway, they're both efficient (if well compiled).
    Probably you'd need a library or something similar and you should see if
    it's available in C or C++.

    Bye

    Andrea

    Comment

    • Ioannis Vranos

      #3
      Re: C++ vs C

      natush wrote:
      [color=blue]
      > Hello,
      > I'm writing an embedded application and I'm trying to decide whether to
      > do it in C or C++. Does anyone know where I can find some statistic
      > data comparing the two languages (size and performance)?[/color]



      http://www.research.att.com/~bs/esc99.html






      --
      Ioannis Vranos


      Comment

      • Matthias

        #4
        Re: C++ vs C

        natush wrote:[color=blue]
        > Hello,
        > I'm writing an embedded application and I'm trying to decide whether to
        > do it in C or C++. Does anyone know where I can find some statistic
        > data comparing the two languages (size and performance)?
        >
        > Thanks,
        > Nataly
        >[/color]

        If you head for more abstraction in your code, then C++ is probably your
        choice. As for code size and performance, this depends mostly on:

        1. Your skill with the language
        2. The quality of your compiler

        If I were you, I'd check out what you really need in terms of code
        complexity. Do you only need data abstraction and procedures? Then C is
        probably what you're looking for.
        Do you need a higher level of abstraction (classes)? Do you need highly
        flexible code (generics)? Then C++ is probably the language of choice.

        --
        Regards,
        Matthias

        Comment

        • bjarne

          #5
          Re: C++ vs C


          Ioannis Vranos wrote:[color=blue]
          > natush wrote:
          >[color=green]
          > > Hello,
          > > I'm writing an embedded application and I'm trying to decide[/color][/color]
          whether to[color=blue][color=green]
          > > do it in C or C++. Does anyone know where I can find some statistic
          > > data comparing the two languages (size and performance)?[/color]
          >
          >
          >
          > http://www.research.att.com/~bs/esc99.html
          >
          > http://www23.brinkster.com/noicys/do...eaking-cpp.pdf
          >[/color]

          Not bad sources :-) but for more solid information see the ISO C++
          committee's technical report on performance:
          http://www.research.att.com/~bs/performanceTR.pdf

          -- Bjarne Stroustrup; http://www.research.att.com/~bs

          Comment

          • Mohd Hanafiah Abdullah

            #6
            Re: C++ vs C

            In article <1108242187.527 90@athnrd02>,
            Ioannis Vranos <ivr@remove.thi s.grad.com> wrote:[color=blue]
            >natush wrote:
            >[color=green]
            >> Hello,
            >> I'm writing an embedded application and I'm trying to decide whether to
            >> do it in C or C++. Does anyone know where I can find some statistic
            >> data comparing the two languages (size and performance)?[/color]
            >
            >
            >
            >http://www.research.att.com/~bs/esc99.html
            >
            >http://www23.brinkster.com/noicys/do...eaking-cpp.pdf[/color]

            You can see:


            for an index on programming languages in terms of popularity.

            Napi

            --


            Comment

            • Ioannis Vranos

              #7
              Re: C++ vs C

              Mohd Hanafiah Abdullah wrote:
              [color=blue]
              > You can see:
              > http://www.tiobe.com/tpci.htm
              >
              > for an index on programming languages in terms of popularity.[/color]


              This seems to agree in the general notion that C/C++ is no 1, however it
              looks strange that C is number 1 and C++ number 2, since the opposite is
              known to be generally true (for example IDC developer report of 2001
              where it was mentioned that C/C++ was number 1 worldwide with C++ being
              the most percent of it).




              --
              Ioannis Vranos


              Comment

              • Jerry Coffin

                #8
                Re: C++ vs C

                Mohd Hanafiah Abdullah wrote:

                [ ... ]
                [color=blue]
                > You can see:
                > http://www.tiobe.com/tpci.htm
                >
                > for an index on programming languages in terms of popularity.[/color]

                This appears highly suspect to me. Ignoring C and C++ for the moment,
                they show Verilog as being behind VHDL -- yet even the staunchest
                advocates of VHDL generally agree that Verilog has a much larger market
                share (probably 5 times as large).

                Ultimately, they're measuring one thing, but reporting it as something
                else entirely. What they're measuring seems to be mostly the number of
                _posts_ about a language. Unfortunately, they're _reporting_ this as
                indicating the number of lines of code written in that language.
                TTBOMK, nobody has ever shown a direct relationship between the two. At
                least IME, the relationship is mostly inverse -- when I'm cranking out
                a lot of code, I rarely have time to post much.

                Likewise, revisions to a language (contemplated or recent) tend to
                generate a great deal of discussion. The code is written later, after
                the language is (again) well understood and the discussion has largely
                died down.

                Personally, I think we can do quite a bit better by searching for
                strings that are likely to occur once (and only once) per source file
                to get at least a vague notion of the number of files in each language:

                string hits
                "import java.io" 902,000
                "include <stdio.h>" 879,000
                "include <iostream>" 404,000
                "include <iostream.h>" 154,000

                [Note: these numbers varied over even a short period of time -- maybe
                Google was doing a crawl, or updating results from its last one, while
                I was doing the searches. If you re-do the searches, expect results to
                vary, but only slightly, at least if you re-do them soon.]

                This has to be done carefully to produce meaningful results though.
                Just for example, searching for "import java" produces over 2 million
                hits, but a single Java source file will often start off three or four
                import lines. Likewise this ignores the length of each piece of source
                code (which probably varies with language), the percentage of code
                written in that language that's visible to Google (e.g. probably a LOT
                lower for COBOL than for C, C++ or Java), etc. Finally, I've made no
                attempt to isolate particular dates like they're doing.

                Even with all these shortcomings, I suspect it's still a better measure
                of quantity of source code than looking for mentions of the language.

                As mentioned above, I'm fairly sure some languages generate a higher
                ratio of discussion to source code than others. For example, searching
                for "java.io" instead of "import java.io" more than triples the number
                of hits. By contrast, searching for 'iostream' without the 'include'
                only increases the number of hits by about 50%. I, at least, would tend
                to assume that in both cases the "extra" hits are mostly in
                documentation, discussions, etc.

                In the end, I'm a bit surprised that the results don't differ even more
                greatly.

                --
                Later,
                Jerry.

                The universe is a figment of its own imagination.

                Comment

                • Ioannis Vranos

                  #9
                  Re: C++ vs C

                  Jerry Coffin wrote:[color=blue]
                  >
                  > This appears highly suspect to me. Ignoring C and C++ for the moment,
                  > they show Verilog as being behind VHDL -- yet even the staunchest
                  > advocates of VHDL generally agree that Verilog has a much larger market
                  > share (probably 5 times as large).
                  >
                  > Ultimately, they're measuring one thing, but reporting it as something
                  > else entirely. What they're measuring seems to be mostly the number of
                  > _posts_ about a language. Unfortunately, they're _reporting_ this as
                  > indicating the number of lines of code written in that language.
                  > TTBOMK, nobody has ever shown a direct relationship between the two. At
                  > least IME, the relationship is mostly inverse -- when I'm cranking out
                  > a lot of code, I rarely have time to post much.
                  >
                  > Likewise, revisions to a language (contemplated or recent) tend to
                  > generate a great deal of discussion. The code is written later, after
                  > the language is (again) well understood and the discussion has largely
                  > died down.
                  >
                  > Personally, I think we can do quite a bit better by searching for
                  > strings that are likely to occur once (and only once) per source file
                  > to get at least a vague notion of the number of files in each language:
                  >
                  > string hits
                  > "import java.io" 902,000
                  > "include <stdio.h>" 879,000
                  > "include <iostream>" 404,000
                  > "include <iostream.h>" 154,000
                  >
                  > [Note: these numbers varied over even a short period of time -- maybe
                  > Google was doing a crawl, or updating results from its last one, while
                  > I was doing the searches. If you re-do the searches, expect results to
                  > vary, but only slightly, at least if you re-do them soon.]
                  >
                  > This has to be done carefully to produce meaningful results though.
                  > Just for example, searching for "import java" produces over 2 million
                  > hits, but a single Java source file will often start off three or four
                  > import lines. Likewise this ignores the length of each piece of source
                  > code (which probably varies with language), the percentage of code
                  > written in that language that's visible to Google (e.g. probably a LOT
                  > lower for COBOL than for C, C++ or Java), etc. Finally, I've made no
                  > attempt to isolate particular dates like they're doing.
                  >
                  > Even with all these shortcomings, I suspect it's still a better measure
                  > of quantity of source code than looking for mentions of the language.
                  >
                  > As mentioned above, I'm fairly sure some languages generate a higher
                  > ratio of discussion to source code than others. For example, searching
                  > for "java.io" instead of "import java.io" more than triples the number
                  > of hits. By contrast, searching for 'iostream' without the 'include'
                  > only increases the number of hits by about 50%. I, at least, would tend
                  > to assume that in both cases the "extra" hits are mostly in
                  > documentation, discussions, etc.
                  >
                  > In the end, I'm a bit surprised that the results don't differ even more
                  > greatly.[/color]



                  Actually google contains hits of web sites that are portals/index
                  Usenet, and from that you may conclude how accurate these things are in
                  relation to jobs. Absolutely none.



                  For example we may reach the conclusion that photographers are the 70%
                  of the population jobs. :-)




                  --
                  Ioannis Vranos


                  Comment

                  • Matthias

                    #10
                    Re: C++ vs C

                    Jerry Coffin wrote:[color=blue]
                    > Unfortunately, they're _reporting_ this as
                    > indicating the number of lines of code written in that language.[/color]

                    No, read again:

                    "Observe that the TPC index is not about the best programming language
                    or the language in which most lines of code have been written."

                    But overall I tend to agree that this index should be interpreted with
                    care, leave alone taking it as an accurate measurement for popularity of
                    programming languages.

                    --
                    Regards,
                    Matthias

                    Comment

                    • Jerry Coffin

                      #11
                      Re: C++ vs C

                      Matthias wrote:

                      [ ... ]
                      [color=blue]
                      > No, read again:
                      >
                      > "Observe that the TPC index is not about the best programming
                      > language or the language in which most lines of code have been
                      > written."[/color]

                      Oops -- you're quite right, I misread it.

                      --
                      Later,
                      Jerry.

                      The universe is a figment of its own imagination.

                      Comment

                      • Julie

                        #12
                        Re: C++ vs C

                        natush wrote:[color=blue]
                        > Hello,
                        > I'm writing an embedded application and I'm trying to decide whether to
                        > do it in C or C++. Does anyone know where I can find some statistic
                        > data comparing the two languages (size and performance)?[/color]

                        In my personal embedded development experience, compared to C++, C is the
                        preferred language: smaller code and less buggy compilers

                        Comment

                        • Ioannis Vranos

                          #13
                          Re: C++ vs C

                          Julie wrote:
                          [color=blue]
                          > In my personal embedded development experience, compared to C++, C is
                          > the preferred language: smaller code and less buggy compilers[/color]


                          I have no experience of embedded programming, and just from curiosity,
                          what kind of embedded devices do you have in mind? (For example I have
                          in mind mainly Pocket PC handhelds with Windows CE and compact .net
                          framework).




                          --
                          Ioannis Vranos


                          Comment

                          • Default User

                            #14
                            Re: C++ vs C


                            Julie wrote:[color=blue]
                            > natush wrote:[color=green]
                            > > Hello,
                            > > I'm writing an embedded application and I'm trying to decide[/color][/color]
                            whether to[color=blue][color=green]
                            > > do it in C or C++. Does anyone know where I can find some statistic
                            > > data comparing the two languages (size and performance)?[/color]
                            >
                            > In my personal embedded development experience, compared to C++, C is[/color]
                            the[color=blue]
                            > preferred language: smaller code and less buggy compilers[/color]

                            Julie touches on one of the major points. Often choice of language for
                            an embedded application has to do with the available tools for the
                            platform. Having a better or more complete compiler/debugger/analyzer
                            for one OS/language combination can drive that selection regardless of
                            other factors.



                            Brian

                            Comment

                            • Chris Hills

                              #15
                              Re: C++ vs C

                              In article <1108412893.697 653@athnrd02>, Ioannis Vranos
                              <ivr@remove.thi s.grad.com> writes[color=blue]
                              >Julie wrote:
                              >[color=green]
                              >> In my personal embedded development experience, compared to C++, C is
                              >> the preferred language: smaller code and less buggy compilers[/color]
                              >
                              >
                              >I have no experience of embedded programming, and just from curiosity,
                              >what kind of embedded devices do you have in mind? (For example I have
                              >in mind mainly Pocket PC handhelds with Windows CE and compact .net
                              >framework).[/color]


                              Most embedded engineers would see a Pocket PC as a small PC not an
                              embedded system. For serious embedded work WIN CE and .net is not an
                              option. Many embedded systems have a MTBF of 20 years. re-boots are not
                              an option.

                              The vast majority of embedded systems use 8 bit processors and have no
                              OS. About 60% of all processors produced are 8 bit I think. The average
                              car has over 50 embedded processors in it. Also virtually anything with
                              electric power on it usually has an embedded MCU (or two) in it.
                              Washing machines, microwaves, phones, hi-fi, missiles, torpedoes, locks,
                              elevators, any control or monitoring system, alarms,




                              /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                              \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\
                              /\/\/ chris@phaedsys. org www.phaedsys.org \/\/
                              \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

                              Comment

                              Working...