Re: New C++ FAQ

Discussion in 'C++' started by Öö Tiib, Mar 24, 2014.

  1. Öö Tiib

    Öö Tiib Guest

    On Monday, 24 March 2014 20:40:06 UTC+2, Paavo Helde wrote:
    > Just reflecting the news from http://soylentnews.org/article.pl?sid=
    > 14/03/24/1626217
    >
    > It appears there is now a more complete and more official(?) C++ FAQ at
    > http://isocpp.org/faq (announcement: http://isocpp.org/blog/2014/03/faq).
    >
    > Marshall Cline is listed as a major contributor for the new FAQ. Should we
    > now start to refer to the new FAQ in this group instead of the one from
    > parashift.com?


    I don't like it too lot.

    Q: Why do my compiles take so long?

    A: Stroupstrup's answer that I won't buy ever:

    You may have a problem with your compiler. It may be old, you may have
    it installed wrongly, or your computer might be an antique. I can't
    help you with such problems. However, it is more likely that the
    program that you are trying to compile is poorly designed ...
    ... (Further it suggests usage of abstract base classes and virtual
    inheritance to decouple interface from implementation
    Shape/Circle/Triangle)

    Nah. Modula had interface and implementation of module finely separated
    1976. We however get compiler that is shewing multi-mega-bytes of
    #include-expanded text at 2014. That is just from standard library and
    one gets nowhere with only standard library. Also dynamic polymorphism
    feels red herring here, does not save one from that design problem
    of language *but* may make end program significantly less efficient.
    Öö Tiib, Mar 24, 2014
    #1
    1. Advertising

  2. Öö Tiib

    Ian Collins Guest

    Öö Tiib wrote:
    > On Monday, 24 March 2014 20:40:06 UTC+2, Paavo Helde wrote:
    >> Just reflecting the news from http://soylentnews.org/article.pl?sid=
    >> 14/03/24/1626217
    >>
    >> It appears there is now a more complete and more official(?) C++ FAQ at
    >> http://isocpp.org/faq (announcement: http://isocpp.org/blog/2014/03/faq).
    >>
    >> Marshall Cline is listed as a major contributor for the new FAQ. Should we
    >> now start to refer to the new FAQ in this group instead of the one from
    >> parashift.com?

    >
    > I don't like it too lot.
    >
    > Q: Why do my compiles take so long?


    A:

    Your machine is too slow :)

    The more technical answer on most systems I use is your compilation
    units and or functions are too big. Both of these impede parallel or
    distributed building.

    --
    Ian Collins
    Ian Collins, Mar 24, 2014
    #2
    1. Advertising

  3. Öö Tiib

    Öö Tiib Guest

    On Tuesday, 25 March 2014 01:36:25 UTC+2, Ian Collins wrote:
    > Öö Tiib wrote:
    > > On Monday, 24 March 2014 20:40:06 UTC+2, Paavo Helde wrote:
    > >> Just reflecting the news from http://soylentnews.org/article.pl?sid=
    > >> 14/03/24/1626217
    > >>
    > >> It appears there is now a more complete and more official(?) C++ FAQ at
    > >> http://isocpp.org/faq (announcement: http://isocpp.org/blog/2014/03/faq).
    > >>
    > >> Marshall Cline is listed as a major contributor for the new FAQ. Should we
    > >> now start to refer to the new FAQ in this group instead of the one from
    > >> parashift.com?

    > >
    > > I don't like it too lot.
    > >
    > > Q: Why do my compiles take so long?

    >
    > A:
    >
    > Your machine is too slow :)
    >
    > The more technical answer on most systems I use is your compilation
    > units and or functions are too big. Both of these impede parallel or
    > distributed building.


    Machine? No. Your build farm takes too few server rooms and your code
    is too huge. Why you wrote millions of lines? Write hello word like all
    normal people. Why you wrote/generated another millions of unit tests?
    What tests? Eyeball it yourself and if it looks OK after few feeble
    tries deploy away.
    Öö Tiib, Mar 24, 2014
    #3
  4. Öö Tiib

    Ian Collins Guest

    Paavo Helde wrote:
    > Ian Collins <> wrote in
    > news::
    >
    >> Öö Tiib wrote:
    >>>
    >>> Q: Why do my compiles take so long?

    >>
    >> A:
    >>
    >> Your machine is too slow :)
    >>
    >> The more technical answer on most systems I use is your compilation
    >> units and or functions are too big. Both of these impede parallel or
    >> distributed building.

    >
    > Or "too many templates" or "your DLL is too big". I have witnessed a design
    > where most of the functionality of the application is placed into a single
    > monolithic shared library; this has some advantages, but it takes ages to
    > link and it seems current linkers cannot parallelize this in any way.


    I agree, large libraries also impede unit testing and some debugging
    tricks (especially memory access checking, which can be per library on
    my system).

    --
    Ian Collins
    Ian Collins, Mar 25, 2014
    #4
  5. Öö Tiib

    Jorgen Grahn Guest

    On Mon, 2014-03-24, Öö Tiib wrote:
    > On Tuesday, 25 March 2014 01:36:25 UTC+2, Ian Collins wrote:
    >> Öö Tiib wrote:
    >> > On Monday, 24 March 2014 20:40:06 UTC+2, Paavo Helde wrote:
    >> >> Just reflecting the news from http://soylentnews.org/article.pl?sid=
    >> >> 14/03/24/1626217
    >> >>
    >> >> It appears there is now a more complete and more official(?) C++ FAQ at
    >> >> http://isocpp.org/faq (announcement: http://isocpp.org/blog/2014/03/faq).
    >> >>
    >> >> Marshall Cline is listed as a major contributor for the new FAQ. Should we
    >> >> now start to refer to the new FAQ in this group instead of the one from
    >> >> parashift.com?
    >> >
    >> > I don't like it too lot.
    >> >
    >> > Q: Why do my compiles take so long?

    >>
    >> A:
    >>
    >> Your machine is too slow :)
    >>
    >> The more technical answer on most systems I use is your compilation
    >> units and or functions are too big. Both of these impede parallel or
    >> distributed building.

    >
    > Machine? No. Your build farm takes too few server rooms and your code
    > is too huge. Why you wrote millions of lines? Write hello word like all
    > normal people. Why you wrote/generated another millions of unit tests?
    > What tests? Eyeball it yourself and if it looks OK after few feeble
    > tries deploy away.


    Do people really have problems with this? My /most recent/ computer
    is a ten years old single core AMD64, and I don't see any single
    compilation take any significant time. I also use a program called
    'make' which allows me to rebuild only things needing to be rebuilt.

    Granted, I don't play with extreme template metaprogramming ... but I
    /do/ use the standard library and I know there's a lot of text
    hitting the preprocessor.

    My /guess/ is the build system rather than the compiler is responsible
    for most frustratingly long or expensive build times. Building the
    same things over and over again, doing a lot of things not related to
    compiling, preventing parallelization and so on. And another favorite
    annoyance of mine: doing the build across really slow remote
    filesystems instead of normal local disk.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Mar 25, 2014
    #5
  6. Öö Tiib

    Öö Tiib Guest

    On Tuesday, 25 March 2014 21:37:17 UTC+2, Jorgen Grahn wrote:
    > On Mon, 2014-03-24, Öö Tiib wrote:
    > > On Tuesday, 25 March 2014 01:36:25 UTC+2, Ian Collins wrote:
    > >> Öö Tiib wrote:
    > >> > On Monday, 24 March 2014 20:40:06 UTC+2, Paavo Helde wrote:
    > >> >> Just reflecting the news from http://soylentnews.org/article.pl?sid=
    > >> >> 14/03/24/1626217
    > >> >>
    > >> >> It appears there is now a more complete and more official(?) C++ FAQ at
    > >> >> http://isocpp.org/faq (announcement: http://isocpp.org/blog/2014/03/faq).
    > >> >>
    > >> >> Marshall Cline is listed as a major contributor for the new FAQ. Should we
    > >> >> now start to refer to the new FAQ in this group instead of the one from
    > >> >> parashift.com?
    > >> >
    > >> > I don't like it too lot.
    > >> >
    > >> > Q: Why do my compiles take so long?
    > >>
    > >> A:
    > >>
    > >> Your machine is too slow :)
    > >>
    > >> The more technical answer on most systems I use is your compilation
    > >> units and or functions are too big. Both of these impede parallel or
    > >> distributed building.

    > >
    > > Machine? No. Your build farm takes too few server rooms and your code
    > > is too huge. Why you wrote millions of lines? Write hello word like all
    > > normal people. Why you wrote/generated another millions of unit tests?
    > > What tests? Eyeball it yourself and if it looks OK after few feeble
    > > tries deploy away.

    >
    > Do people really have problems with this? My /most recent/ computer
    > is a ten years old single core AMD64, and I don't see any single
    > compilation take any significant time. I also use a program called
    > 'make' which allows me to rebuild only things needing to be rebuilt.


    Linking alone can take 15 minutes for bit bigger program. Indeed
    I already said that "hello word" links in fraction of seconds. Also 15
    minutes may be "fast like hell" and "no significant time" for lot of
    people.

    > Granted, I don't play with extreme template metaprogramming ... but I
    > /do/ use the standard library and I know there's a lot of text
    > hitting the preprocessor.


    No need for to use template metaprogramming at all to get compile times.
    just download and compile some code that does something. No need
    to go extreme with compiling mozilla or clang or something deep like
    that ... just piece of software that is not thin wrapper/ui on some
    prebuilt library but really does anything itself.

    > My /guess/ is the build system rather than the compiler is responsible
    > for most frustratingly long or expensive build times. Building the
    > same things over and over again, doing a lot of things not related to
    > compiling, preventing parallelization and so on. And another favorite
    > annoyance of mine: doing the build across really slow remote
    > filesystems instead of normal local disk.


    If there are 1000 files that compile 3 seconds in average (say 1 to 5
    seconds) and linking takes 15 minutes then you can parallelize it up
    to 15 minutes and 5 seconds; on one core it takes one hour and 5
    minutes.
    Öö Tiib, Mar 26, 2014
    #6
  7. Öö Tiib

    Öö Tiib Guest

    On Wednesday, 26 March 2014 17:58:00 UTC+2, Scott Lurndal wrote:
    > =?ISO-8859-1?Q?=D6=F6_Tiib?= <> writes:
    > >Linking alone can take 15 minutes for bit bigger program.

    >
    > Some examples would be nice. Even the linux kernel, hardly a small
    > program, will link in less than 60 seconds, and the entire build
    > is well under 15 minutes (depending on the number of cores assigned to
    > the build, it can be much less).


    Linux kernel isn't written in C++ AFAIK.

    > I used compilers in the 70's that would compile at less than
    > 100 source lines per minute. Those days are long gone.


    Bjarne started with "C with classes" early 80's AFAIK so that was not C++.

    > >No need for to use template metaprogramming at all to get compile times.

    >
    > Hmm. Current project:
    >
    > SLOC counts:
    >
    > cpp: 264919 (52.61%)
    > ansic: 226578 (44.99%)
    > python: 9985 (1.98%)
    > asm: 1839 (0.37%)
    > sh: 258 (0.05%)
    >
    > $ time make -j 6 QUIET=true
    > real 0m29.83s
    > user 2m24.84s
    > sys 0m10.64s
    >
    > Two year old intel, 4 HT cores @ 3.2Ghz, spinning media.


    Not sure what you have there, C compiled with C++ compiler?

    For example only linking Chromium no compiling
    http://en.wikipedia.org/wiki/Chromium_(web_browser) can take
    one day and several gigabytes of memory. It is about 7 millions
    of sloc mostly C++.
    Öö Tiib, Mar 26, 2014
    #7
  8. Öö Tiib

    jacob navia Guest

    Le 26/03/2014 16:58, Scott Lurndal a écrit :
    > Even the linux kernel, hardly a small
    > program, will link in less than 60 seconds, and the entire build
    > is well under 15 minutes (depending on the number of cores assigned to
    > the build, it can be much less).


    The linux kernel is written in C, not C++.

    That is why it is fast
    jacob navia, Mar 26, 2014
    #8
  9. Öö Tiib

    Melzzzzz Guest

    On Wed, 26 Mar 2014 18:20:08 +0100
    jacob navia <> wrote:

    > Le 26/03/2014 16:58, Scott Lurndal a écrit :
    > > Even the linux kernel, hardly a small
    > > program, will link in less than 60 seconds, and the entire build
    > > is well under 15 minutes (depending on the number of cores assigned
    > > to the build, it can be much less).

    >
    > The linux kernel is written in C, not C++.


    Yes. Linus just hates C++.

    >
    > That is why it is fast


    Oh, questionable ;)
    That's why it has smaller memory footprint, for sure.

    --
    Click OK to continue...
    Melzzzzz, Mar 26, 2014
    #9
  10. Öö Tiib

    Osmium Guest

    "Melzzzzz" wrote:

    >Yes. Linus just hates C++.


    >> That is why it is fast


    >Oh, questionable ;)
    >That's why it has smaller memory footprint, for sure.


    Hello world in C is a 19 KB executable on my machine, C++ takes 570KB. FWIW
    a 30:1 ratio.
    Osmium, Mar 26, 2014
    #10
  11. Osmium schreef op 26-Mar-14 8:45 PM:> "Melzzzzz" wrote:
    >
    >> Yes. Linus just hates C++.

    >
    >>> That is why it is fast

    >
    >> Oh, questionable ;)
    >> That's why it has smaller memory footprint, for sure.

    >
    > Hello world in C is a 19 KB executable on my machine, C++ takes

    570KB. FWIW
    > a 30:1 ratio.


    That is mainly caused by the stdout library, and the way the libraries
    are organized. I use C++ to build images for small microcontrollers. The
    equivalent of 'hello world' on a microcontroler is 'blink a led', which
    in my environment is about the same size for C and C++ when the
    comparison is made fairly: same functionality, C++ features that are not
    suited to a small system (RTTI, exceptions) disabled.

    Wouter
    Wouter van Ooijen, Mar 26, 2014
    #11
  12. Öö Tiib

    Ian Collins Guest

    Osmium wrote:
    > "Melzzzzz" wrote:
    >
    >> Yes. Linus just hates C++.

    >
    >>> That is why it is fast

    >
    >> Oh, questionable ;)
    >> That's why it has smaller memory footprint, for sure.

    >
    > Hello world in C is a 19 KB executable on my machine, C++ takes 570KB. FWIW
    > a 30:1 ratio.


    You must have a very strange system.

    i7> cat hw.c
    #include <stdio.h>
    int main() { puts("hello world"); }

    i7> c99 -fast /tmp/hw.c; ls -o a.out
    -rwxr-xr-x 1 ian 6724 Mar 27 08:53 a.out

    i7> CC -fast /tmp/hw.c; ls -o a.out
    -rwxr-xr-x 1 ian 8292 Mar 27 08:54 a.out

    i7> cat hw.cc
    #include <iostream>
    int main() { std::cout << "hello world" << std::endl; }

    i7> CC -fast /tmp/hw.cc; ls -o a.out
    -rwxr-xr-x 1 ian 9568 Mar 27 08:54 a.out

    --
    Ian Collins
    Ian Collins, Mar 26, 2014
    #12
  13. Öö Tiib

    Jorgen Grahn Guest

    On Wed, 2014-03-26, Scott Lurndal wrote:
    > =?ISO-8859-1?Q?=D6=F6_Tiib?= <> writes:
    >>On Tuesday, 25 March 2014 21:37:17 UTC+2, Jorgen Grahn wrote:
    >>> On Mon, 2014-03-24, =D6=F6 Tiib wrote:

    ....
    >>> > is too huge. Why you wrote millions of lines? Write hello word like all
    >>> > normal people. Why you wrote/generated another millions of unit tests?
    >>> > What tests? Eyeball it yourself and if it looks OK after few feeble
    >>> > tries deploy away.
    >>>
    >>> Do people really have problems with this? My /most recent/ computer
    >>> is a ten years old single core AMD64, and I don't see any single
    >>> compilation take any significant time. I also use a program called
    >>> 'make' which allows me to rebuild only things needing to be rebuilt.

    >>
    >>Linking alone can take 15 minutes for bit bigger program.

    >
    > Some examples would be nice. Even the linux kernel, hardly a small
    > program, will link in less than 60 seconds, and the entire build
    > is well under [...]


    Yes. In my experience, linking is always fast (a second or two).
    But my experience is limited to:
    - the Gnu linker
    - linking static and shared libraries, not hundreds of individual
    object files.
    - traditional compilation + linking, not that gcc mode where the
    compilation is really performed at the linking stage.

    I /did/ once work in a project where linking took minutes and used 500
    MB of RAM (my project leader ended up buying extra RAM for us, so our
    PCs didn't spend /another/ 30 minutes swapping). But that was some
    commercial toolchain for an embedded ARM platform, and I think it's
    safe to say that linker was badly written.

    I think it had some extra features which could explain the low
    performance, but I don't remember what they were ... not anything
    I found useful, anyway.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Mar 26, 2014
    #13
  14. Öö Tiib

    Jorgen Grahn Guest

    On Wed, 2014-03-26, Osmium wrote:
    > "Melzzzzz" wrote:
    >
    >>Yes. Linus just hates C++.

    >
    >>> That is why it is fast

    >
    >>Oh, questionable ;)
    >>That's why it has smaller memory footprint, for sure.

    >
    > Hello world in C is a 19 KB executable on my machine, C++ takes 570KB. FWIW
    > a 30:1 ratio.


    Your machine is strange: the C++ version is 8K on my machine.

    (Hasn't this been beaten to death, since a decade or two?)

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Mar 26, 2014
    #14
  15. Öö Tiib

    Öö Tiib Guest

    On Wednesday, 26 March 2014 20:31:14 UTC+2, Scott Lurndal wrote:
    > =?ISO-8859-1?Q?=D6=F6_Tiib?= <> writes:
    > > For example only linking Chromium no compiling
    > > http://en.wikipedia.org/wiki/Chromium_(web_browser) can take
    > > one day and several gigabytes of memory. It is about 7 millions
    > > of sloc mostly C++

    >
    > Likely indicative of poor design. Is this your personal experience
    > or are you relating an anecdote?


    Not exactly personal experience but I have lot of trust in source. Not
    sure what is "whole day" maybe it took 14 hours to link not 24. That
    chromium is codebase of most popular web browser at the moment.
    So if it is bad design then there is vacant slot on huge market for
    good or great design. ;-)
    Öö Tiib, Mar 26, 2014
    #15
  16. Öö Tiib

    Osmium Guest

    "Jorgen Grahn" wrote:

    > On Wed, 2014-03-26, Osmium wrote:
    >> "Melzzzzz" wrote:
    >>
    >>>Yes. Linus just hates C++.

    >>
    >>>> That is why it is fast

    >>
    >>>Oh, questionable ;)
    >>>That's why it has smaller memory footprint, for sure.

    >>
    >> Hello world in C is a 19 KB executable on my machine, C++ takes 570KB.
    >> FWIW
    >> a 30:1 ratio.

    >
    > Your machine is strange: the C++ version is 8K on my machine.
    >
    > (Hasn't this been beaten to death, since a decade or two?)


    Probably, most things have.

    I thought they were both exorbitant, I recall a neat little C reprogram that
    did scads of useful things on an Atari ST that was 28K.But 570K is way
    beyond exorbitant. It is DevC which people keep saying is MingW packaged
    with an IDE. I don't obsess about these things, I am trying to live a life
    here.

    You do realize that these were different programs, written as "natively" as
    possible?

    Here is the C++ version. The cin s make debugging easier.
    -----
    #include <iostream>

    int main()
    {
    using namespace std;
    cout << "Hello world\n";
    char x;
    cin >> x;
    cin >> x;
    }
    Osmium, Mar 26, 2014
    #16
  17. Öö Tiib

    Melzzzzz Guest

    On Wed, 26 Mar 2014 14:45:34 -0500
    "Osmium" <> wrote:

    > "Melzzzzz" wrote:
    >
    > >Yes. Linus just hates C++.

    >
    > >> That is why it is fast

    >
    > >Oh, questionable ;)
    > >That's why it has smaller memory footprint, for sure.

    >
    > Hello world in C is a 19 KB executable on my machine, C++ takes
    > 570KB. FWIW a 30:1 ratio.
    >
    >


    Statically linked?
    C++ produces awful lot more symbols that's for sure.

    --
    Click OK to continue...
    Melzzzzz, Mar 26, 2014
    #17
  18. Öö Tiib

    Osmium Guest

    "Melzzzzz" <> wrote in message
    news:lgve7v$385$...
    > On Wed, 26 Mar 2014 14:45:34 -0500
    > "Osmium" <> wrote:
    >
    >> "Melzzzzz" wrote:
    >>
    >> >Yes. Linus just hates C++.

    >>
    >> >> That is why it is fast

    >>
    >> >Oh, questionable ;)
    >> >That's why it has smaller memory footprint, for sure.

    >>
    >> Hello world in C is a 19 KB executable on my machine, C++ takes
    >> 570KB. FWIW a 30:1 ratio.
    >>
    >>

    >
    > Statically linked?


    Yes.
    Osmium, Mar 26, 2014
    #18
  19. Öö Tiib

    Ian Collins Guest

    Osmium wrote:
    >
    > You do realize that these were different programs, written as "natively" as
    > possible?


    So were my examples.

    > Here is the C++ version. The cin s make debugging easier.
    > -----
    > #include <iostream>
    >
    > int main()
    > {
    > using namespace std;
    > cout << "Hello world\n";
    > char x;
    > cin >> x;
    > cin >> x;
    > }


    9016 bytes on my box.

    --
    Ian Collins
    Ian Collins, Mar 26, 2014
    #19
  20. Öö Tiib

    David Brown Guest

    On 26/03/14 22:12, Ian Collins wrote:
    > Osmium wrote:
    >>
    >> You do realize that these were different programs, written as
    >> "natively" as
    >> possible?

    >
    > So were my examples.
    >
    >> Here is the C++ version. The cin s make debugging easier.
    >> -----
    >> #include <iostream>
    >>
    >> int main()
    >> {
    >> using namespace std;
    >> cout << "Hello world\n";
    >> char x;
    >> cin >> x;
    >> cin >> x;
    >> }

    >
    > 9016 bytes on my box.
    >


    It's about 8K on mine, 5K after strip. But I can get up to 74K with
    "-g3" - perhaps with more debugging symbols enabled the result could be
    bigger. And on a Windows machine, there could be a bunch of large
    windows-specific stuff that is also included, as well as static linking
    of translation layers between the roughly posix environment that mingw
    gives to the programmer, and the non-standard environment that windows
    gives to the program.
    David Brown, Mar 27, 2014
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-15?Q?Juli=E1n?= Albo

    FAQ or not FAQ?

    =?ISO-8859-15?Q?Juli=E1n?= Albo, Jan 8, 2007, in forum: C++
    Replies:
    28
    Views:
    865
    Grizlyk
    Jan 15, 2007
  2. Josef 'Jupp' Schugt
    Replies:
    0
    Views:
    202
    Josef 'Jupp' Schugt
    Sep 22, 2003
  3. FAQ server

    FAQ - How do I direct someone to this FAQ?

    FAQ server, Aug 4, 2006, in forum: Javascript
    Replies:
    1
    Views:
    158
    Dr John Stockton
    Aug 4, 2006
  4. Peter Michaux

    FAQ/FAQ notes site makeover

    Peter Michaux, Nov 22, 2006, in forum: Javascript
    Replies:
    22
    Views:
    358
    Randy Webb
    Nov 27, 2006
  5. Replies:
    2
    Views:
    450
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page