|Ada vs. C performance, was Possible to write compiler to Java VM? firstname.lastname@example.org (Arch Robison) (1997-01-07)|
|Ada and C email@example.com (Brian A Wichmann) (1997-01-09)|
|From:||Brian A Wichmann <firstname.lastname@example.org>|
|Date:||9 Jan 1997 22:01:54 -0500|
|Keywords:||Ada, C, performance|
>>[Do Ada compilers really generate better code than C compilers for similar
>>source code? -John]
> I have one anecdotal data point that says no. While working for my
> former employer, I was asked to investigate why a new piece of
> software written in Ada was so much slower than its old counterpart in
> Fortran. The presumed reason was "new feature and flexibility bloat".
> But profiling indicated the problem was really with some basic
> old-fashioned numerical inner loops. Not being strong on Fortran, I
> rewrote the loops in C for comparison. The C was at least 2x faster.
> Inspection of the assembly code indicated that the Ada compiler was
> lacking fundamental optimizations present in the C compiler.
> This is of course a single data point, probably obsolete. But I think
> there is a strong reason to suspect that C compilers will generally
> generate better code than Ada compilers. Quality of code is
> ultimately not a technology issue; it is an economics issue.
> Optimizers (and the rest of compilers) are as good as what people are
> willing to pay for, and the C market is much bigger. (Data points to
> the contrary cheerfully accepted!)
I am not convinced. The Ada market is good enough to support high
quality compilers. There are several around, but there is a risk that
the compiler required on a specific platform is not ideal - but that
applies to C as well!
There is no fundamental reason why Ada code should execute slower than
C code *given a fair comparison*. However, if you take non- Ada code
and convert it to Ada and campare with C, then the result could be
very poor for Ada indeed. The reason is simple: Ada *requires* that
checks are performed and C does not. If the compiler can optimise the
checks away, then fine, but not otherwise.
There are several cases in which Ada compilers can produce
fundamentally superior code to C. Examples are as follows:
1. Using the ability in Ada to in-line a function.
2. Using ability in Ada control the representation of a type
so that the compiler performs bit manipulation for data
3. All cases in which C optimization is unsafe due to the
inability of the compiler to detect if aliasing is present.
(The C standard is very careful here, but your compiler
might not be!)
Brian Wichmann Tele: +44 181 943 6976 (direct)
National Physical Laboratory FAX: +44 181 977 7091
Teddington Middlesex e-mail: email@example.com
Return to the
Search the comp.compilers archives again.