From: | macrakis@osf.org (Stavros Macrakis) |
Newsgroups: | comp.lang.java,comp.compilers,comp.lang.ada |
Date: | 9 Feb 1996 16:52:52 -0500 |
Organization: | OSF Research Institute |
References: | 96-01-037 96-01-130 96-02-051 |
Keywords: | C, design |
Our moderator said:
[This is again straying too far from compilers; we all know how easy
it is to write awful C code, but I don't see that it has much direct
bearing on compiler construction. Feel free to show that I'm mistaken
if I am....]
Actually, there is a very direct bearing. There are several C
features which make garbage collection difficult (although not
impossible, as shown by the conservative collectors on the one hand
and the interpretive C approach on the other), notably casts, untagged
unions, and arrays without well-defined run-time lengths. There are
also several features that make certain optimizations pretty much
impossible, namely the possibility of almost arbitrary aliasing.
Moreover, the low level of the language means that, although it is
very easy to generate OK code for C, it is hard to optimize operations
on higher-level structures, such as multidimensional arrays, and
generate excellent code, especially on machines whose architecture is
very different (e.g. distributed memory MIMD) from the flat byte
address space, monoprocessor model implicit in C.
These are the same features that can make program understanding,
verification, and maintenance difficult.
Ada doesn't have many of these problems. On the other hand, compilers
have to work much harder both for semantic analysis and for good code
generation. But the features that cause these optimization
difficulties are features that increase safety (e.g. range checking).
There are some unsafe features in Ada other than the explicit ones.
For instance, aliasing is "erroneous" (thus allowing efficient
Fortran-style optimization of array code in subroutines), but no
runtime checking is required.
-s
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.