ahodgson@hstbme.mit.edu (Antony Hodgson) (11/06/90)
I've been using Turbo C++ almost exclusively over the past few months, but I recently went back to a Turbo Pascal v5.5 program I'd written earlier and was amazed at the high speed of compilation and linking. This got me wondering what it was about the differences in the structure of Pascal and C++ that forces the compilation of C++ to be so slow (I'm assuming, of course, that Borland applied roughly the same level of compiler design expertise to both projects). What does it have to do with the differences between TPUs and OBJ files? Any ideas, anyone? Tony Hodgson ahodgson@hstbme.mit.edu
dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (11/07/90)
In article <1990Nov6.155350.9586@athena.mit.edu> ahodgson@hstbme.mit.edu.UUCP (Antony Hodgson) writes: >I've been using Turbo C++ almost exclusively over the past few months, >but I recently went back to a Turbo Pascal v5.5 program I'd written >earlier and was amazed at the high speed of compilation and linking. This >got me wondering what it was about the differences in the structure of >Pascal and C++ that forces the compilation of C++ to be so slow (I'm >assuming, of course, that Borland applied roughly the same level of >compiler design expertise to both projects). What does it have to do >with the differences between TPUs and OBJ files? TPU files have a couple of features that make linking and compiling external references faster: - all externals are resolved at compile time as pointers to specific locations in the header of the referenced .TPU file. In C++, you recompile header files every time, don't you? This also speeds up linking, because the linker doesn't have to look up externals by name, it already knows the location. The downside is that you have to recompile units every time the header of a unit that they use is changed. This is why Borland doesn't worry about tinkering with the TPU format with each new version: your existing .TPU files would be obsolete anyways, because the headers of the system units are bound to be different. - .TPU files are organized for random access: there are several hash tables within them to make lookups of identifiers fast during compiling. With C++, the compiler has to build its own hash table from the header file, and the linker has to live with the slow .OBJ format, which is essentially a sequential list of records (unless Borland puts an index in as a COMENT). I think those are the main reasons, but the general fact that .TPU files aren't portable even between different versions of the same compiler probably means Borland has taken some trouble to optimize the format for speed. The .OBJ format is pretty old now. Duncan Murdoch