comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: C vs. Ada (was "C is better ...)
Date: 1996/08/09
Date: 1996-08-09T00:00:00+00:00	[thread overview]
Message-ID: <dewar.839608170@schonberg> (raw)
In-Reply-To: g1wwz9ud46.fsf@hotspec.lanl.gov


"   William Clodius points out:
     "...most optimizations are performed in the language-independent
      backends.  ...  Strong typing in any language helps with optimization,
      and both C and Ada ... have strong typing.""


It is true that most optimizations are performed in LI backends

(well let's say that this is the case with some technologies, not all,
certainly, for example, many Ada 83 code generators were Ada specific
backends).

It is also true that strong typing helps, but C definitely lacks the
helpful strong typing.

   in Ada if we see

       X.all := 3;

   and X is of type access my_integer, where my_integer is derived from
   integer, then we now that a variable of type integer cannot be
   disturbed by this assignment.

   The equivalent in C

      *x = 3;

   can destroy any int variable.

In general the amount of aliasing and typing information sent to the
backend, even an LI backend, is very much language dependent, and
clearly Ada is in a position to send much more aliasing and typing
information along. That does not mean the backend necessarily takes
advantage of this possibility, but at an abstract language level,
there really IS a difference between C and Ada from an optimization
point of view, and potentially this means that a perfectly optimizing
Ada compiler can typically do better than a perfectly optimizing C
compiler, where perfectly optimizating means generating optimal code
using all the conceptually available information from the front end.

Note that real compilers are only (quite imperfect) approximations
to "perfectly optimizing" compilers, so whether this effect is actually
visible in practice is hard to say.





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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-07  0:00 C vs. Ada (was "C is better ...) W. Wesley Groleau (Wes)
1996-08-08  0:00 ` William Clodius
1996-08-09  0:00   ` Robert Dewar [this message]
replies disabled

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