
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
[EMAIL PROTECTED] (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
| <-- __Chronological__ --> | <-- __Thread__ --> |