Re: C vs. Ada performance

Walter Banks <>
4 Jan 1997 20:51:17 -0500

          From comp.compilers

Related articles
Re: Possible to write compiler to Java VM? (W. Wesley Groleau (Wes)) (1997-01-02)
Re: C vs. Ada performance (1997-01-03)
Re: C vs. Ada performance (Walter Banks) (1997-01-04)
Re: C vs. Ada performance (Dean Sutherland) (1997-01-07)
Re: C vs. Ada performance (1997-01-12)
| List of all articles for this month |

From: Walter Banks <>
Newsgroups: comp.compilers
Date: 4 Jan 1997 20:51:17 -0500
Organization: Byte Craft Limited
References: 97-01-019 97-01-032
Keywords: C, Ada, performance

> [Do Ada compilers really generate better code than C compilers for similar
> source code? -John]

Wilbur Streett wrote:
> Ada compilers do more because they are farther away from abstraction
> of the hardware. That doesn't mean that the resulting code generated
> is faster, it means that the Ada code is typically written farther
> away from the hardware level in the first place.

It is a myth that only C can have close access to the underlying
hardware. Most languages can do this. What I find supprising is how
liitle C code that I see actually does that. (We write C compilers for
embedded systems)

> I would imagine that a good C coder would consistently generate
> faster code than an Ada programmer would.

How about a "good" C programmer against a "good" Ada programmer both
with good compilers.

> There's much less chance that a C programmer would
> get very far away from the most optimized algorithms, since the
> abstraction is so close to the hardware level.

The problem in C is not the closness that a programmer is to the
target machine but the level of optimization that a compiler can apply
to a language without breaking the application intent. C's strength is
also its biggest weakness. Our compilers often interpret source code
fragments so that we can understand the programmer's intent and our
optimization limitations this time.

Good compilers will often have much better code generation algorithms
than programmers writing code. Before I get flammed this is something
compiler developers focus on as their primary task.

> Claims that Ada generates faster code seem like a straw horse to me,
> as Ada as a language reminds me so much of PL/I. Optimization by
> the compiler may be a good thing, but nothing beats code that is
> written cleanly in the first place.

No optimizer will change a bubble sort into a quick sort. In C vs Ada
we have two good high level languages. Ada is easier to optimize. C
has a lot of flexibility.

Walter Banks

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.