Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: EXE file size, C vs. Pascal Summary: EXE file size is red herring Message-ID: <510@taumet.com> Date: 10 Nov 90 16:22:08 GMT Distribution: comp Organization: Taumetric Corporation, San Diego Lines: 38 nuspljj@mentor.cc.purdue.edu (Joseph J. Nuspl Jr.) writes: >Over the past year, I have written several Unix-like commands -- cat, ls, ... >in Turbo Pascal 5.5. I have recently rewritten them in Turbo C++ hoping >to improve speed and/or reduce file size. The C compiled programs are >significanly larger. Cat in Pascal is ~3k, Turbo C ~17, DeSmet C ~10. Once again, someone is confusing linked program size with efficiency. If you are going to put this program in ROM, EXE file size is important. Otherwise, it is likely to be irrelevent. EXE files may contain data other than program code and data. It may contain data which is never loaded into memory, such as debugging information. Turbo C in particular includes information about exactly which source and object files were used, and their dates and times, as well as the date and time of the link. None of this gets loaded at run time, but it does take up space. If you write cat in C in terms of standard I/O (), you will be including a lot of library code which has far more capability than you need for the program. Depending on how the I/O package is divided into modules, you may include code which is never executed. If you care to sacrifice portability in favor of small EXE size, you can write in terms of low-level open, close, read, and write calls. These are supported by most C systems, and you will not need to link in the standard I/O package. The program may be faster as well. The way to determine which programs are more efficient is to measure their performance, not to look at the numer of bytes in the EXE file. You also may wish to consider how easy it is to get the functionality you need in your program, and how robust your program is likely to be. I do not claim that you will get better results in C than in Pascal, but that you are using the wrong criterion for judgement. -- Steve Clamage, TauMetric Corp, steve@taumet.com