Related articles |
---|
Compile speed: Pascal(Delphi) vs C++ Chavoux@yahoo.com (2003-11-11) |
Re: Compile speed: Pascal(Delphi) vs C++ fjh@cs.mu.oz.au (Fergus Henderson) (2003-11-11) |
Re: Compile speed: Pascal(Delphi) vs C++ lu.nn@wischik.com (Lucian Wischik) (2003-11-11) |
Re: Compile speed: Pascal(Delphi) vs C++ marcov@stack.nl (Marco van de Voort) (2003-11-21) |
Re: Compile speed: Pascal(Delphi) vs C++ robert.thorpe@antenova.com (Rob Thorpe) (2003-11-21) |
Re: Compile speed: Pascal(Delphi) vs C++ vbdis@aol.com (2003-11-21) |
Re: Compile speed: Pascal(Delphi) vs C++ randyhyde@earthlink.net (Randall Hyde) (2003-11-21) |
Re: Compile speed: Pascal(Delphi) vs C++ marcov@stack.nl (Marco van de Voort) (2003-12-03) |
Re: Compile speed: Pascal(Delphi) vs C++ marcov@stack.nl (Marco van de Voort) (2003-12-03) |
[6 later articles] |
From: | Lucian Wischik <lu.nn@wischik.com> |
Newsgroups: | comp.compilers |
Date: | 11 Nov 2003 23:05:42 -0500 |
Organization: | University of Bologna |
References: | 03-11-048 |
Keywords: | performance, practice |
Posted-Date: | 11 Nov 2003 23:05:42 EST |
Chavoux@yahoo.com (Chavoux) wrote:
>A question: my brother wrote the same programme (fairly large and
>using database and networking) in both Delphi and Borland C Builder.
>Apparantly the C Builder version took huge ammounts of time to
>compile. (So much so that he switched back to rewriting everything in
>Delphi).
>I am not familiar at all with the internals of the compilers of these
>languages, but I would like to know why this is the case?
In Pascal, when you import a unit's interface, it can be imported just
as a straight binary dump of the symbol table. In C++, when you
#include a header file, it has to include it textually because
previous stuff (e.g. #defines) can completely change the meaning of a
header file. That means that each .cpp file amounts to 25,500 lines of
code that the compiler has to parse -- 25,000 for the headers, 500 for
the code. In Pascal it only parses 500 lines.
Well, this isn't quite true. In C++Builder and Visual Studio and
probably other C++ compilers, you can use extra directives to let the
compiler use "precompiled headers" -- ie. if two .cpp files use
exactly the same headers, in exactly the same sequence, with no clever
features, then the compiler can save a binary dump of this. In
C++Builder the .pch files take upwards of 15Mb. (whereas the pascal
unit files take maybe 50k each -- so there's still the speed
difference).
I remember the story of the C programmer who switched to Delphi, wrote
a very large program, clicked the Compile button, and nothing seemed
to happen. He thought there must have been a bug in the Delphi IDE.
Why wasn't it compiling? -- turns out it was compiling the entire
program, in a fraction of a second, so quickly he hadn't even noticed.
(I understand that Borland put a lot more effort into fast-compilation
of Delphi than most compiler vendors do, but don't know where I heard
this.)
--
Lucian
Return to the
comp.compilers page.
Search the
comp.compilers archives again.