[comp.lang.c] Code space efficiency re-examined.

SARGON%UMASS.BITNET@wiscvm.wisc.EDU (04/27/87)

> From:     doug@edge.uucp
> Subject:  Re: Portable C vs Efficient C or "Cost of Portability"
>
> And even with the decent optimizing compilers, code size in C is awful.  See
> the discussion in comp.sys.amiga about how to get "hello, world" down from
> 8K to 1K!  In assembler, it'd be maybe 50 bytes.
>
> -- Doug Pardee -- Edge Computer Corp. -- Scottsdale, Arizona

Ive seen this argument one too many times. How much of that 1K is
code that the compiler generated versus from the run time library which
which the program is linked to?
The systems Ive worked with link a run time library to compiled object
code for every compiler.  If your library is 1K and your application
is 100K then your library doesnt make up 1% of your total object code
size.  WHEN shared libraries become common in operating systems
(window manager inferface libraries that are a few hundred K long
are going to make this mandatory) the length of the run time library
simply wont matter.
If C had a code size ratio of 20:1 I really dont think it would have
caught on.  A realistic figure (from "Design of the UNIX Operating
System" by Maurice J. Bach, page 4) a typical figure might be much
closer to 20-40% larger and slower.  With 68020s replacing 68000s and
386s replacing 8088s you are talking a 4 fold increase in processing
power, so the loss in speed caused by the compiler is truly negligable
for the majority of applications that you plan to run on assorted
architectures.
Finally, in light of the rumored "10:1" ratio of an assembly language
source to a C source Id much rather port 10,000 lines of C from a
VAX to a Sun than 100,000 lines of VAX assembly to 100,000 lines of
68020 assembly.  The world has moved into multivendor networks that
run sophisticated programs. The days of writing more versions of
'wc' and other little utilities have given way to major software projects.
With systems like the Mac II and other micro/workstation class machines
appearing for personal computer prices running UN*X, NFS and X
on networks with Suns and VAXen and other machines the need for
applications which are architecturally transparent as well as network
transparent is even stronger.
Leave the specialty work for assembly, and the "hello, world" stuff
to BASIC. I bet it comes out shorter than 50 bytes.
~~~~~~
Stephen Halpin             sargon@umass.bitnet (nothing to do with chess)