Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #9589 > unrolled thread

Generally, are the programs written by C++ slower than written by C 10% ?

Started byKaiWen <wenkai1987@gmail.com>
First post2011-09-01 01:41 -0700
Last post2011-09-03 15:11 -0700
Articles 14 on this page of 114 — 22 participants

Back to article view | Back to comp.lang.c++


Contents

  Generally, are the programs written by C++ slower than written by C 10% ? KaiWen <wenkai1987@gmail.com> - 2011-09-01 01:41 -0700
    Re: Generally, are the programs written by C++ slower than written by C   10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-01 21:15 +1200
    Re: Generally, are the programs written by C++ slower than written by C 10% ? "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2011-09-01 11:48 +0200
      Re: Generally, are the programs written by C++ slower than written by C 10% ? Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-01 15:34 -0700
        Re: Generally, are the programs written by C++ slower than written by C 10% ? KaiWen <wenkai1987@gmail.com> - 2011-09-01 19:09 -0700
          Re: Generally, are the programs written by C++ slower than written by   C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-02 14:39 +1200
          Re: Generally, are the programs written by C++ slower than written by C 10% ? Krice <paulkp@mbnet.fi> - 2011-09-01 22:33 -0700
          Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-02 01:12 -0500
            Re: Generally, are the programs written by C++ slower than written by C 10% ? James Kanze <james.kanze@gmail.com> - 2011-09-03 15:25 -0700
              Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-04 01:34 -0500
                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-04 02:33 -0700
                Re: Generally, are the programs written by C++ slower than written by C 10% ? James Kanze <james.kanze@gmail.com> - 2011-09-04 11:00 -0700
          Re: Generally, are the programs written by C++ slower than written by C 10% ? Goran <goran.pusic@gmail.com> - 2011-09-01 23:23 -0700
            Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-02 03:00 -0700
              Re: Generally, are the programs written by C++ slower than written by C 10% ? Goran <goran.pusic@gmail.com> - 2011-09-02 09:39 -0700
            Re: Generally, are the programs written by C++ slower than written by C 10% ? Rui Maciel <rui.maciel@gmail.com> - 2011-09-02 12:44 +0100
          Re: Generally, are the programs written by C++ slower than written by C 10% ? Rui Maciel <rui.maciel@gmail.com> - 2011-09-02 09:59 +0100
            Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-02 11:25 -0700
          Re: Generally, are the programs written by C++ slower than written by C 10% ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-03 05:51 +0000
            Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-03 01:45 -0700
              Re: Generally, are the programs written by C++ slower than written   by C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-03 20:53 +1200
                Re: Generally, are the programs written by C++ slower than written   by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-03 10:49 -0700
                  Re: Generally, are the programs written by C++ slower than written     by C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-04 08:15 +1200
                    Re: Generally, are the programs written by C++ slower than written     by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-03 17:50 -0700
              Re: Generally, are the programs written by C++ slower than written by C 10% ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-03 16:28 +0000
                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-03 10:42 -0700
                  Re: Generally, are the programs written by C++ slower than written by C 10% ? "Bo Persson" <bop@gmb.dk> - 2011-09-04 11:34 +0200
                    Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-04 09:04 -0700
                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-04 18:04 +0000
                    Re: Generally, are the programs written by C++ slower than written by C 10% ? Keith H Duggar <duggar@alum.mit.edu> - 2011-09-04 18:44 -0700
                    Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-04 23:26 -0700
                      Re: Generally, are the programs written by C++ slower than written by C 10% ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-05 08:01 +0000
                        Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-05 11:45 -0700
                          Re: Generally, are the programs written by C++ slower than written by C 10% ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-06 06:30 +0000
                            Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-06 07:22 -0700
                          Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-06 16:25 +0900
                            Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-06 07:14 -0700
                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-07 12:28 +0900
                                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-07 16:49 -0700
                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Noah Roberts <roberts.noah@gmail.com> - 2011-09-07 18:45 -0700
                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-08 15:56 -0700
              Re: Generally, are the programs written by C++ slower than written by C 10% ? James Kanze <james.kanze@gmail.com> - 2011-09-03 15:32 -0700
                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-03 19:16 -0700
              Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-05 00:28 -0700
                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-05 12:34 -0700
                  Re: Generally, are the programs written by C++ slower than written   by C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-06 07:51 +1200
                    Re: Generally, are the programs written by C++ slower than written   by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-05 14:06 -0700
                      Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-06 00:32 -0700
                        Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-06 07:33 -0700
                          Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-07 02:52 -0700
                            Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-08 16:24 -0700
                              Re: Generally, are the programs written by C++ slower than written   by C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-09 11:38 +1200
                                Re: Generally, are the programs written by C++ slower than written   by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-08 21:39 -0700
                                  Re: Generally, are the programs written by C++ slower than written     by C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-09 19:01 +1200
                                    Re: Generally, are the programs written by C++ slower than written     by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-09 02:45 -0700
                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-09 03:23 -0700
                                    Re: Generally, are the programs written by C++ slower than written     by C 10% ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-14 23:12 +0000
                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-09 02:40 -0700
                                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-09 11:19 -0700
                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-09 15:42 -0500
                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-09 14:24 -0700
                                      Re: Generally, are the programs written by C++ slower than written by C 10% ? Noah Roberts <roberts.noah@gmail.com> - 2011-09-09 18:22 -0700
                                        Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-10 10:11 -0700
                                          Re: Generally, are the programs written by C++ slower than written by C 10% ? Noah Roberts <roberts.noah@gmail.com> - 2011-09-10 10:54 -0700
                                            Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-10 14:28 -0700
                                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-11 12:29 +0900
                                                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-11 00:45 -0700
                                                Re: Generally, are the programs written by C++ slower than written by C 10% ? Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-12 00:39 -0700
                                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-12 18:06 +0900
                                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-12 16:46 -0700
                                                      Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-13 10:20 +0900
                                                        Re: Generally, are the programs written by C++ slower than written by C 10% ? Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-13 13:16 -0700
                                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Nobody <nobody@nowhere.com> - 2011-09-11 04:53 +0100
                                                Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-11 14:51 +0900
                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-10 07:46 -0700
                    Re: Generally, are the programs written by C++ slower than written by C 10% ? KaiWen <wenkai1987@gmail.com> - 2011-09-06 03:10 -0700
                      Re: Generally, are the programs written by C++ slower than written by   C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-06 22:50 +1200
                        Re: Generally, are the programs written by C++ slower than written by C 10% ? KaiWen <wenkai1987@gmail.com> - 2011-09-06 04:48 -0700
                          Re: Generally, are the programs written by C++ slower than written by C 10% ? yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-09-07 09:45 +0000
                            Re: Generally, are the programs written by C++ slower than written by   C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-07 21:51 +1200
                            Re: Generally, are the programs written by C++ slower than written by C 10% ? KaiWen <wenkai1987@gmail.com> - 2011-09-08 00:15 -0700
                              Re: Generally, are the programs written by C++ slower than written by C 10% ? yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-09-08 12:14 +0000
                                Re: Generally, are the programs written by C++ slower than written by C 10% ? KaiWen <wenkai1987@gmail.com> - 2011-09-08 07:14 -0700
                        Re: Generally, are the programs written by C++ slower than written by C 10% ? Asger-P <junk@asger-p.dk> - 2011-09-06 13:52 +0200
                      Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-06 11:47 -0500
                        Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-06 11:50 -0500
                        Re: Generally, are the programs written by C++ slower than written by C 10% ? Asger-P <junk@asger-p.dk> - 2011-09-06 21:04 +0200
                          Re: Generally, are the programs written by C++ slower than written by C 10% ? Leigh Johnston <leigh@i42.co.uk> - 2011-09-06 20:37 +0100
                            Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-06 15:10 -0500
                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Leigh Johnston <leigh@i42.co.uk> - 2011-09-06 21:14 +0100
                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Asger-P <junk@asger-p.dk> - 2011-09-07 00:40 +0200
                                Re: Generally, are the programs written by C++ slower than written by C 10% ? Leigh Johnston <leigh@i42.co.uk> - 2011-09-06 23:59 +0100
                                Re: Generally, are the programs written by C++ slower than written by C 10% ? Noah Roberts <roberts.noah@gmail.com> - 2011-09-06 16:26 -0700
                          Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-06 14:55 -0500
                            Re: Generally, are the programs written by C++ slower than written by C 10% ? Asger-P <junk@asger-p.dk> - 2011-09-07 00:51 +0200
                              Re: Generally, are the programs written by C++ slower than written by C 10% ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-06 23:29 -0500
                                Re: Generally, are the programs written by C++ slower than written by C 10% ? Asger-P <junk@asger-p.dk> - 2011-09-07 09:06 +0200
                                  Re: Generally, are the programs written by C++ slower than written by   C 10% ? Ian Collins <ian-news@hotmail.com> - 2011-09-07 19:09 +1200
                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Nobody <nobody@nowhere.com> - 2011-09-07 13:19 +0100
                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-07 13:01 +0000
                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Rui Maciel <rui.maciel@gmail.com> - 2011-09-07 14:26 +0100
                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? Asger-P <junk@asger-p.dk> - 2011-09-07 15:49 +0200
                                  Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-08 22:49 -0700
                                    Re: Generally, are the programs written by C++ slower than written by C 10% ? Miles Bader <miles@gnu.org> - 2011-09-09 15:25 +0900
                                      Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-09 02:50 -0700
                                        Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-09 03:26 -0700
                                      Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-09 03:25 -0700
                  Re: Generally, are the programs written by C++ slower than written by C 10% ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-06 00:24 -0700
              Re: Generally, are the programs written by C++ slower than written by C 10% ? yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-09-06 13:57 +0000
                Re: Generally, are the programs written by C++ slower than written by C 10% ? BGB <cr88192@hotmail.com> - 2011-09-06 08:18 -0700
          Re: Generally, are the programs written by C++ slower than written by C 10% ? Nobody <nobody@nowhere.com> - 2011-09-03 08:34 +0100
    Re: Generally, are the programs written by C++ slower than written by C 10% ? "A" <a@a.a> - 2011-09-01 11:50 +0200
    Re: Generally, are the programs written by C++ slower than written by C 10% ? Rui Maciel <rui.maciel@gmail.com> - 2011-09-01 10:53 +0100
    Re: Generally, are the programs written by C++ slower than written by C 10% ? James Kanze <james.kanze@gmail.com> - 2011-09-03 15:11 -0700

Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]


#9900

FromRui Maciel <rui.maciel@gmail.com>
Date2011-09-07 14:26 +0100
Message-ID<4e677102$0$6807$a729d347@news.telepac.pt>
In reply to#9868
Asger-P wrote:

> Well then I better ask how You get the console window to stay open
> long enough to read the result, when doing a build and run.?
> if You dont use something like getch();

Doesn't windows provide a command line?  It it doesn't then you can always 
run your command line program through some script which, after running the 
program, calls pause.  At least this was possible in the Windows 9[58] days.  
Do the recent incantations of windows still support batch files?


Rui Maciel

[toc] | [prev] | [next] | [standalone]


#9901

FromAsger-P <junk@asger-p.dk>
Date2011-09-07 15:49 +0200
Message-ID<op.v1fx1eb12juju3@ajwin7>
In reply to#9900
Hi Rui

On the: 07. of september-2011 At: 15:26 Rui Maciel wrote:

> Asger-P wrote:
>
>> Well then I better ask how You get the console window to stay open
>> long enough to read the result, when doing a build and run.?
>> if You dont use something like getch();
>
> Doesn't windows provide a command line?

Ooh, yes and it also handles batch files.
I have posted a question in embarcadero.public.cppbuilder.ide
to see if there is a setting that will do, if not I think I'll
stick with std::cin.get();

Thanks anyway
Best regards
Asger-P

[toc] | [prev] | [next] | [standalone]


#9954

FromBGB <cr88192@hotmail.com>
Date2011-09-08 22:49 -0700
Message-ID<j4c9cr$t30$1@news.albasani.net>
In reply to#9868
On 9/7/2011 12:06 AM, Asger-P wrote:
>
> Hi Paavo
>
> On the: 07. of september-2011 At: 06:29 Paavo Helde wrote:
>
>
>>>>> getch();
>>>>
>>>> Not a standard function
>>>
>>> It's just me never doing any commandline apps. ;-)
>>> Do You really care about that :O
>>
>> It means other people can not just copy-paste your code and compile-run
>> it by themselves.
>
> Well then I better ask how You get the console window to stay open
> long enough to read the result, when doing a build and run.?
> if You dont use something like getch();
>

FWIW, there are also "getc();" and "fgetc(stdin);" which are at least 
more standard, but are also C-style, unlike "cin.get();" which is more 
properly C++ (by whatever logic this makes sense, I don't get people 
sometimes, as everything works either way, but whatever...).


but, stdio vs iostreams is another long and eventually pointless debate...

[toc] | [prev] | [next] | [standalone]


#9957

FromMiles Bader <miles@gnu.org>
Date2011-09-09 15:25 +0900
Message-ID<buo7h5ixmf5.fsf@dhlpc061.dev.necel.com>
In reply to#9954
BGB <cr88192@hotmail.com> writes:
> FWIW, there are also "getc();" and "fgetc(stdin);" which are at least
> more standard, but are also C-style, unlike "cin.get();" which is more
> properly C++ (by whatever logic this makes sense, I don't get people
> sometimes, as everything works either way, but whatever...).
>
> but, stdio vs iostreams is another long and eventually pointless debate...

No doubt, but it does make sense in many cases to at least prefer one
or another, because _mixing_ them can be problematic and/or
inefficient.

-Miles

-- 
Alliance, n. In international politics, the union of two thieves who have
their hands so deeply inserted in each other's pockets that they cannot
separately plunder a third.

[toc] | [prev] | [next] | [standalone]


#9965

FromBGB <cr88192@hotmail.com>
Date2011-09-09 02:50 -0700
Message-ID<j4cnhv$shp$1@news.albasani.net>
In reply to#9957
On 9/8/2011 11:25 PM, Miles Bader wrote:
> BGB<cr88192@hotmail.com>  writes:
>> FWIW, there are also "getc();" and "fgetc(stdin);" which are at least
>> more standard, but are also C-style, unlike "cin.get();" which is more
>> properly C++ (by whatever logic this makes sense, I don't get people
>> sometimes, as everything works either way, but whatever...).
>>
>> but, stdio vs iostreams is another long and eventually pointless debate...
>
> No doubt, but it does make sense in many cases to at least prefer one
> or another, because _mixing_ them can be problematic and/or
> inefficient.
>

probably...

but, yeah, I, unsurprisingly, fall more on the stdio side of this issue, 
and personally don't like iostreams as much on an aesthetic basis 
(visually, it still seems a bit much like, someone, long ago, was like 
"wow, cool, I have operator overloading" and decided to make heavy use 
of it for the console interface, and whether or not this is a good idea? 
who really knows...).

[toc] | [prev] | [next] | [standalone]


#9969

FromNick Keighley <nick_keighley_nospam@hotmail.com>
Date2011-09-09 03:26 -0700
Message-ID<88dd092f-82a1-4b24-81d1-35e513b4e76c@o10g2000vby.googlegroups.com>
In reply to#9965
On Sep 9, 10:50 am, BGB <cr88...@hotmail.com> wrote:
> On 9/8/2011 11:25 PM, Miles Bader wrote:
>
> > BGB<cr88...@hotmail.com>  writes:
> >> FWIW, there are also "getc();" and "fgetc(stdin);" which are at least
> >> more standard, but are also C-style, unlike "cin.get();" which is more
> >> properly C++ (by whatever logic this makes sense, I don't get people
> >> sometimes, as everything works either way, but whatever...).
>
> >> but, stdio vs iostreams is another long and eventually pointless debate...
>
> > No doubt, but it does make sense in many cases to at least prefer one
> > or another, because _mixing_ them can be problematic and/or
> > inefficient.
>
> probably...
>
> but, yeah, I, unsurprisingly, fall more on the stdio side of this issue,
> and personally don't like iostreams as much on an aesthetic basis
> (visually, it still seems a bit much like, someone, long ago, was like
> "wow, cool, I have operator overloading" and decided to make heavy use
> of it for the console interface, and whether or not this is a good idea?
> who really knows...).

I have to agree it gets pretty ugly as soon as you want to format
anything. I seem to rad the manual a lot more tahn I remmeber doing
with printf() (but maybe I forget how much of a PITA printf() was in
the beginning)

[toc] | [prev] | [next] | [standalone]


#9967

FromNick Keighley <nick_keighley_nospam@hotmail.com>
Date2011-09-09 03:25 -0700
Message-ID<1ebe6866-243a-4e80-b5e8-0e27e01ff065@h7g2000yqm.googlegroups.com>
In reply to#9957
On Sep 9, 7:25 am, Miles Bader <mi...@gnu.org> wrote:
> BGB <cr88...@hotmail.com> writes:
> > FWIW, there are also "getc();" and "fgetc(stdin);" which are at least
> > more standard, but are also C-style, unlike "cin.get();" which is more
> > properly C++ (by whatever logic this makes sense, I don't get people
> > sometimes, as everything works either way, but whatever...).
>
> > but, stdio vs iostreams is another long and eventually pointless debate...
>
> No doubt, but it does make sense in many cases to at least prefer one
> or another, because _mixing_ them can be problematic and/or
> inefficient.

and iostreams are extensible. It's hard to make printf() print a user
defined type but relativly easy to make operator<< do it

[toc] | [prev] | [next] | [standalone]


#9782

FromNick Keighley <nick_keighley_nospam@hotmail.com>
Date2011-09-06 00:24 -0700
Message-ID<51b55bf4-59bb-45c2-9f73-f34cc2dc8e2a@d18g2000yqm.googlegroups.com>
In reply to#9764
On Sep 5, 8:34 pm, BGB <cr88...@hotmail.com> wrote:
> On 9/5/2011 12:28 AM, Nick Keighley wrote:
> > On Sep 3, 9:45 am, BGB<cr88...@hotmail.com>  wrote:

<snip>

> >> also, just how many people really use "qsort()" anyways?...
>
> > If I'm coding in C and I want to sort something. My first thought
> > would be qsort()! If it was too slow only then would I consider hand
> > coding it. Surely any constructively lazy person would use an existing
> > facility rather hand-roll their own!
>
> different styles for different sorts...

why? Why not use something that is good-enough? Scraping an extra nano-
second off an infrequently run routine is hardly ever worth the
bother.


> actually, in my case I would probably far more likely copy-paste it and
> then edit it to the new use.
>
> copy-paste is a powerful tool which is often disparaged and overlooked.

copy-paste is the route of all evil. I've suggested (only half joking)
that the single best way to improve the quality of software world-wide
is to disable the copy-paste facility. Or slightly hurt the programmer
every time he uses it.

> but, one would typically write it themselves initially (before
> subjecting it to endless copy-paste).

gag. Why not package it a proper reusable component? (function,
template, macro, package). Then just reuse it. You're trying to drag
us back to the software engineering of the neolithic.

> >> IME, it is more often one of those largely forgotten functions (it is
> >> there, but more often people write out their own sort logic manually).
>
> > why?! There must be nearly as many badly written sort routines as
> > there are badly implemented linked lists!
>
> if people were not doing it, then one would not be encountering them.

so tell them to stop! Don't encourage them!


> that one is encountering so many "badly written sort functions" means
> that there are equally many (probably actually, far more) people off
> writing them.
>
> hence, the case stands...

hence use the bloody library routine

<snip>

> there are also plenty of things often done with C strings as well that
> can make them faster, such as interning them so that one can check
> string equality using '==' on the pointers, rather than using
> "!strcmp()", ...
>
> in my case, I tend to avoid "stdrup()" as well, as generally "strdup()"
> is a good way to "make bad things happen"

which is probably why strdup() is non-standard


> (slow, tears through huge
> amounts of memory, leaves the program responsible to free them, ...), [...]

<snip>

[toc] | [prev] | [next] | [standalone]


#9800

Fromyatremblay@bel1lin202.(none) (Yannick Tremblay)
Date2011-09-06 13:57 +0000
Message-ID<j458t6$l3h$2@dont-email.me>
In reply to#9687
In article <j3speo$h90$1@news.albasani.net>, BGB  <cr88192@hotmail.com> wrote:
>On 9/2/2011 10:51 PM, Juha Nieminen wrote:
>> KaiWen<wenkai1987@gmail.com>  wrote:
>>> 2. In runtime, the speed of the program written by C++ is<= the same
>>>    program written by C
>>
>>    Actually many equivalent constructs in C and C++ are such that it's
>> the exact opposite: C++ is significantly faster than C.
>>
>>    Just two simple examples are qsort() vs. std::sort() , and strlen()
>> vs std::string::length(). Especially in the first case it's precisely
>> the language features that help the compiler make a faster executable.
>
>this again, comes down to coding practices...
>
>
>also, just how many people really use "qsort()" anyways?...
>IME, it is more often one of those largely forgotten functions (it is 
>there, but more often people write out their own sort logic manually).
>
>(actually, it seems to be fairly common practice in C land for people to 
>largely ignore much of the standard library, and to write their own 
>logic for doing things).

Which has two effects:

1- Waste programmer time.  Time that could otherwised be used to
improve the rest of the program.

2- One of:
   a) Best case: an equivalently well implementation as a quality std
   library 
   b) A working but somewhat poorer implementation that would would
   have been produced but a good dedicated team and tested
   extensively. 
   c) a buggy implementation that comes back to bite you. 

So even in the best case scenario, you are loosing if there is not a
quality standard library available.  

One of the problem with C is that the basic C library offers very
little and nobody agrees on what is a quality generally accepted
extension to it.  So peoples spend time reimplementing the wheel or
re-learning a different third party library.

Yan

[toc] | [prev] | [next] | [standalone]


#9805

FromBGB <cr88192@hotmail.com>
Date2011-09-06 08:18 -0700
Message-ID<j45dk9$btj$1@news.albasani.net>
In reply to#9800
On 9/6/2011 6:57 AM, none Yannick Tremblay wrote:
> In article<j3speo$h90$1@news.albasani.net>, BGB<cr88192@hotmail.com>  wrote:
>> On 9/2/2011 10:51 PM, Juha Nieminen wrote:
>>> KaiWen<wenkai1987@gmail.com>   wrote:
>>>> 2. In runtime, the speed of the program written by C++ is<= the same
>>>>     program written by C
>>>
>>>     Actually many equivalent constructs in C and C++ are such that it's
>>> the exact opposite: C++ is significantly faster than C.
>>>
>>>     Just two simple examples are qsort() vs. std::sort() , and strlen()
>>> vs std::string::length(). Especially in the first case it's precisely
>>> the language features that help the compiler make a faster executable.
>>
>> this again, comes down to coding practices...
>>
>>
>> also, just how many people really use "qsort()" anyways?...
>> IME, it is more often one of those largely forgotten functions (it is
>> there, but more often people write out their own sort logic manually).
>>
>> (actually, it seems to be fairly common practice in C land for people to
>> largely ignore much of the standard library, and to write their own
>> logic for doing things).
>
> Which has two effects:
>
> 1- Waste programmer time.  Time that could otherwised be used to
> improve the rest of the program.
>

yes, but doesn't matter if other people are wasting their time, only if 
they are wasting ones' own time (or oneself is wasting ones' own time 
and has potentially better things to be doing).

given enough people, and a lack of profit motive, then the cost/value of 
most effort ultimately tends towards zero (actually, it is RMS's ideal 
to impose this on all software, but this is not agreeable IMO, as 
commercial people doing their thing still manage to deliver a lot more 
that is usable to "typical end users", and to produce higher-quality 
games with better production values, ...).

it is like, at the moment the high-point of production values in FOSS 
games is still only really up to what commercial games had 10-12 years 
ago (sadly, we don't see any Portal or Portal 2 analogues or similar 
coming from FOSS land at present...).


granted, GIMP and FireFox are pretty good (and Internet Explorer is 
still generally "teh suck"...).


> 2- One of:
>     a) Best case: an equivalently well implementation as a quality std
>     library
>     b) A working but somewhat poorer implementation that would would
>     have been produced but a good dedicated team and tested
>     extensively.
>     c) a buggy implementation that comes back to bite you.
>
> So even in the best case scenario, you are loosing if there is not a
> quality standard library available.
>
> One of the problem with C is that the basic C library offers very
> little and nobody agrees on what is a quality generally accepted
> extension to it.  So peoples spend time reimplementing the wheel or
> re-learning a different third party library.
>

fair enough.

this is probably why, for the most part, projects tend to end up 
creating their own library "platform" and building their code on this, 
rather than using much of the standard C library.

but, then one ends up with issues like largish apps (500 kloc or 1 Mloc 
or more) built on things like GTK+, including many components with 
nothing to do with GUI, which has its own drawbacks.

better options may well just be someone writing their own set of 
run-time libraries (this is basically the main area where my "C 
restriction" is in effect, application code does not have this 
restriction, and libraries may be C++ if they are more "internal logic" 
than "external API").

another option is to use a less-nasty framework (than GTK+), such as SDL 
or similar.

granted, the above doesn't apply to large pre-existing apps, which may 
already be heavily built around GTK+ or whatever.


in some ways, writing software is often not too much different from 
throwing on vasaline in place of thermal grease (say, because one 
doesn't have any thermal grease). it is maybe not as good, or maybe will 
all leak away after a while, but it is a good enough temporary fix until 
next time the issue comes up again (where one does have the grease, or 
worse case, they throw on a new coat of vasaline...).

actually, it works fairly good for things like electric motors, and 
apparently for 4-cycle engines (like in cars/...) as well.

(but, I am more wary of crisco, as things have turned out badly before 
with this one... just because it works good in ovens apparently doesn't 
make it good for electronics even if both use-cases have to deal with 
heat...).

it is not just vegetable shortening, but maybe also electrical shortening...


or such...

[toc] | [prev] | [next] | [standalone]


#9684

FromNobody <nobody@nowhere.com>
Date2011-09-03 08:34 +0100
Message-ID<pan.2011.09.03.07.34.37.266000@nowhere.com>
In reply to#9640
On Thu, 01 Sep 2011 19:09:01 -0700, KaiWen wrote:

> I know I can develop faster by using C++, but the speed of program
> in runtime is important too. So witch one is important? Can anyone
> give a suggestion?

C code is usually either valid C++ code or is trivially modifiable to be
valid C++ code. Whether such code runs faster when compiled as C or as C++
depends upon the quality of the compiler, not the language.

However: C++ has additional features over C. Whether those features make
the program faster or slower depends upon how you use them.

No language feature is inherently "slow". Even if a particular feature has
a performance cost, if it simplifies development then the time saved can
be spent optimising other parts of the code.

The question isn't which language you would use if you wanted absolutely
optimal code (otherwise, everyone would use assembler). The question is
which language will produce the best result given the development time
available.

The answer to that question depends more upon the skill of the programmers
than on the language.

On one hand, C++ has features which will allow a good programmer to both
improve performance and reduce development time simultaneously. On the
other hand, not all programmers are good programmers, and C++ provides
not-so-good programmers with far greater scope for messing up.

[toc] | [prev] | [next] | [standalone]


#9594

From"A" <a@a.a>
Date2011-09-01 11:50 +0200
Message-ID<j3nkib$2as$1@gregory.bnet.hr>
In reply to#9589
It is not actually the language that might be slower because you can do 
equal things in C and C++ that execute approximately the same speed, what 
matters might be overhead that some C++ constructs imply on the program. But 
that is only if you use such constructs... such as templates for example. 
Even templates can also be used in a right and wrong way. So the answer is 
far from being general. In good hands each tool can work wonders or be just 
as average as any other tool.

For example:

std::vector<int> abc;
abc.at(0) = 1; // is slower than
abc[0] = 1; // than this because of range checking

In C you don't even have such constructs so there is nothing to compare it 
to. But if you use at() which does some additional overhead due to range 
checking then of course it is somewhat slower than the other version. It is 
like you would call more functions in C, that would execute slower due to 
heap/stack allocation etc.

But in C++ you could as well write:

char[] abc = "abc";
abc[0] = "x";

that would work equally fast in C or C++.

In general, there is only one REAL issue - which of the two you find more 
valuable - the convenience that C++ offers over C to speedup development... 
or... your time.... to finish a certain project (even if it is a bit 
slower). Remember, programmers time is never getting more expensive it may 
only get cheaper. 

[toc] | [prev] | [next] | [standalone]


#9595

FromRui Maciel <rui.maciel@gmail.com>
Date2011-09-01 10:53 +0100
Message-ID<4e5f560d$0$6001$a729d347@news.telepac.pt>
In reply to#9589
KaiWen wrote:

> Generally, are the programs written by C++ slower than written by C
> 10% ?

Why would they be?

Just for the sake of argument, here are some benchmarks comparing the 
results of a C implementation to those of a C++ implementation.

http://shootout.alioth.debian.org/u64q/cpp.php
http://shootout.alioth.debian.org/u64q/which-programming-languages-are-
fastest.php?gpp=on&gcc=on&calc=chart


Rui Maciel

[toc] | [prev] | [next] | [standalone]


#9707

FromJames Kanze <james.kanze@gmail.com>
Date2011-09-03 15:11 -0700
Message-ID<96aeaddb-64b4-4393-b6d0-62662ad82546@g31g2000yqh.googlegroups.com>
In reply to#9589
On Sep 1, 9:41 am, KaiWen <wenkai1...@gmail.com> wrote:
> Generally, are the programs written by C++ slower than written by C
> 10% ?

No. In general, if performance matters, programs written in C++
are significantly faster than those written in C.  (And if it
doesn't matter, who cares.)  C++ offers better encapsulation,
and better encapsulation makes it significantly easier to
exploit the profiler output.

--
James Kanze

[toc] | [prev] | [standalone]


Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]

Back to top | Article view | comp.lang.c++


csiph-web