comp.lang.ada
 help / color / mirror / Atom feed
From: Vladimir Vukicevic <vladimir@speedy.granite.com>
Subject: Re: Ada vs. C
Date: 1996/08/12
Date: 1996-08-12T00:00:00+00:00	[thread overview]
Message-ID: <wj686o43ln.fsf@speedy.granite.com> (raw)
In-Reply-To: dewar.839592211@schonberg



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  <vladimir@arp.com>  [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




  parent reply	other threads:[~1996-08-12  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-07  0:00 Ada vs. C The Quelisher
1996-08-09  0:00 ` Robert Dewar
1996-08-09  0:00   ` The Quelisher
1996-08-10  0:00     ` steved
1996-08-10  0:00       ` Robert Dewar
1996-08-10  0:00     ` Bob Kitzberger
1996-08-10  0:00     ` Robert Dewar
1996-08-11  0:00     ` Dave Wood
1996-08-14  0:00       ` busigin
1996-08-16  0:00         ` Robert Dewar
1996-08-11  0:00     ` Jerry van Dijk
1996-08-12  0:00   ` Vladimir Vukicevic [this message]
1996-08-09  0:00 ` Jack W Scheible
1996-08-09  0:00 ` Daniel P Hudson
1996-08-09  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1995-01-20  4:43 "Subtract C, add Ada" Samuel Mize
1995-01-21 20:28 ` David O'Brien
     [not found]   ` <3g655n$q5k@theopolis.orl.mmc.com>
1995-01-30 15:33     ` Ada vs. C Martijn Bak
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox