From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,63bbc3281a2f80ea X-Google-Attributes: gid103376,public From: Vladimir Vukicevic Subject: Re: Ada vs. C Date: 1996/08/12 Message-ID: #1/1 X-Deja-AN: 173780771 references: <3208F2BA.E34@freenet.scri.fsu.edu> organization: Best Internet Communications reply-to: vladimir@arp.com newsgroups: comp.lang.ada Date: 1996-08-12T00:00:00+00:00 List-Id: dewar@cs.nyu.edu (Robert Dewar) writes: > > Here is some realistic data on comparing C and Ada. The programs I > compared are: > > [..] > > The stripped executables compiled by gcc are of course identical in > size as one would expect, 24580 bytes in either case. > [..] > I can of course (since gcc allows mixed language programming) make a C > program which uses Text_IO facilities, guess how big it is -- that's right > 53252 bytes (what a surprise :-) > > I suppose these figures may surprise some people, but to me it would > be surprising if comparable C and Ada programs were NOT the same size! Come on, Robert, you can't really believe that C and Ada programs compile into the exact same size, no matter how identical they are. They are very close in size: (f being the ada code, and foo being the C code) -rw-rw-r-- 1 vladimir vladimir 896 Aug 12 15:37 f.o -rw-rw-r-- 1 vladimir vladimir 880 Aug 12 15:38 foo.o However, when compiled into full apps, the ada code needs to have gnatbind needs to do various initialization, and only then call procedure f(). In C, this isn't necessary; as such, the resulting executable files have the following sizes [stripped, all libraries shared]: -rwxrwxr-x 1 vladimir vladimir 6692 Aug 12 15:46 f* -rwxrwxr-x 1 vladimir vladimir 2436 Aug 12 15:47 foo* Why the large size discrepancy? Because f is being linked (albeit shared) with libgnat, libc, libpthread, and libm. foo, on the other hand, is just being linked shared with libc. f also has the overhead of b_f.c, whereas foo does not. This is all rather pointless, actually, since executable file size doesn't have anything to do with memory requirements of the program or running time or whatnot. For comparison purposes, here is an equivalent program in java: public class F { public static void main (String args[]) { System.out.println ("hello world"); } } The resulting runnable code size? -rw-rw-r-- 1 vladimir users 407 Aug 12 15:51 F.class I guess this makes java twice as good as Ada and C :-) - Vladimir -- Vladimir Vukicevic [std disclaimer here] C makes it easy for you to shoot yourself in the foot. C++ makes that harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup