[comp.lang.pascal] EXE file size, C vs. Pascal

nuspljj@mentor.cc.purdue.edu (Joseph J. Nuspl Jr.) (11/10/90)

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.

I will continue my 'Ms-Dix' project and was wondering which platform, C or
Pascal, that I should continue with.  I am trying to keep the size of the
executables small and have the speed of execution as fast as possible.

BTW - I don't have time to code every thing in Assembler.

Comments?

Thanks.

      __    __________    _________
     /_/|  /_________/|  /________/|	Joseph J. Nuspl Jr.
     | ||  |  ____  | |  | _______|/	nuspljj@mentor.cc.purdue.edu
     | ||  | ||   | | |  | ||______
  __ | ||  | ||   | | |  | |/_____/|	Purdue University	
 /_/|| ||  | ||   | | |  | _______|/	Shreve Hall, Room 308
 | ||| ||  | ||___| | |  | ||______	West Lafayette, IN 47906
 | |_| ||  | |/___| | |  | |/_____/|
 |_____|/  |________|/   |________|/	(317) 495-5415

dc@sci.UUCP (D. C. Sessions) (11/13/90)

In article <16398@mentor.cc.purdue.edu> 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.
>
>BTW - I don't have time to code every thing in Assembler.
>
>Comments?

Try writing a null program in each language.  I think you'll find that it's
not so much a function of language as of implementation.

Currently, TP v5.5 has one of the better linkage editors around; it
eliminates dead code fairly efficiently.  (BTW: so does at least one 
Modula-2 system -- in fact, mine is better than TP.)

For filters and the like, speed is going to be a function of I/O buffering
anyway, and again this is implementation- rather than language-bound.

The moral?  Use the language that suits you, and forget about 'efficiency'.
It's a moving target.

-- 
| The above opinions may not be original, but they are mine and mine alone. |
|            "While it may not be for you to complete the task,             |
|                 neither are you free to refrain from it."                 |
+-=-=-    (I wish this _was_ original!)        D. C. Sessions          -=-=-+

eli@smectos.gang.umass.edu (Eli Brandt) (11/15/90)

In article <16398@mentor.cc.purdue.edu> 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.
>
>I will continue my 'Ms-Dix' project and was wondering which platform, C or
>Pascal, that I should continue with.  I am trying to keep the size of the
>executables small and have the speed of execution as fast as possible.
>
>BTW - I don't have time to code every thing in Assembler.
>
>Comments?

Two, neither of them very encouraging.  First, there are already a *lot*
of unix-utility-for-DOS packages, PD ones.  Second, something like ls should
most likely be written in assembly.  Re your .exe-sizes, I'm really not sure
why people expect C to produce tighter code than Pascal.  Presumably a
holdover from massive mainframes, where the C compiler was just *so* much 
better than the COBOL compiler... however, Borland did a nice job on both TP
and TC, so there isn't much difference.  And printf is bigger than writeln,
which probably account for much of your size difference.  Does any renegade
Borland-type know whether Borland uses the same backend for all of its 
compilers?

>
>Thanks.
>

>     /_/|  /_________/|  /________/|	Joseph J. Nuspl Jr.
[sig clipped somewhat]


Disclaimer: UMASS doesn't even know I'm here.
Note that I said "unix" of there, which is fine because the real Un*x is
 case-sensitive.  :-/

Eli