Compile Time

The "ACM Hello World" web page entry for Eiffel (at http://www.latech.edu/~acm/helloworld/eiffel.html) notes that "In case you are interested, this program took (approximatly[sic]) five minutes to compile and generated an executable of around about 2 Meg in size. (That has to be a winner for the most inefficient compiler in history)" [ACMHello]. Certainly older Eiffel compilers had a reputation for slow compilation, excessively large executables, and slow run times. Is this still the case?

Compilation time should probably not be a major factor in choosing tools, but it can really affect the speed and efficiency of the code-compile-debug cycle. As such, I tested compilation time for debug and release builds.

Compilation time was taken in two cases for each language; first, in the default debugging mode, which is the mode used for daily builds and testing. In the C++ case, the command-line arguments "-g -Wall" were used, to denote that debug information should be generated and that full warnings should be given, and no optimizations taken. The equivalent in Eiffel is no arguments at all. For the release build, the C++ compiler was given the argument "-O3" indicating that full optimization was to be performed, and defines were created to ensure that the contract macros were not included in the release build. The Eiffel equivalent was the command-line switch "-boost". The SmallEiffel compiler uses gcc as its back-end, as does g++, so this should be a fairly equitable comparison. The results are interesting indeed.

I gathered results for the debug builds by simply using time make and time compile main make for the respective compilers; user and system time were added for the total. For the debug scores, I averaged three compilation runs; for the release scores, only one run was taken.

For the compile time, executable size, and executable speed comparisons, programs 2a and 3a were not considered, since they were line counters for C++ and Eiffel and could have no common test data.

Compilation times, C++ and Eiffel

Debug compilation time comparison, C++ and Eiffel

These results surprised me considerably! Eiffel has a bad (and apparently undeserved!) reputation as a "slow-to-compile" languages. If my results are any indication, it is anything but; in fact, there's a strong correlation showing that the Eiffel compilation takes roughly 33% of the time that the C++ compilation does in debug mode. And note this very interesting trend-- in the release mode, the C++ compiler takes a bit more time than in debug mode; in Eiffel, the release build takes much less time, less that half in some cases! Look at the results for program 10, where the release C++ program took about 40 seconds to compile, and the eiffel about 6-- and note the remarkable trend that this difference seems to increase as program size increases-- far from the slow, ponderous tool that it's been portrayed as in the past, Eiffel is a lithe and quick little language (or at least the SmallEiffel implementation is). Add to this the fact that Eiffel uses one source file per module (rather than two, as C++) and does automatic dependency analysis (no need for makefiles or manual #includes), and it becomes even more appealing.