This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A FrontEnd in C++?


On 21-Aug-2002, Zack Weinberg <zack@codesourcery.com> wrote:
> 
> It seems that many people are more sanguine about allowing front ends
> to be written in their own languages than I am.  I didn't properly
> explain why I don't like the idea; let me try again.
> 
> There is an intrinsic complexity burden to maintaining a program with
> components written in multiple languages.  You have to have a
> functional compiler and runtime library for each source language, for
> starters.  On top of that, all the languages have to be ABI
> compatible;

That is an overstatement.  The "native" calling conventions used by each
of the different languages do not need to be ABI compatible.  All that is
needed is for the languages to have a way of interfacing with each other.
Most modern languages have a way of interfacing with C.

For example, C++ uses different name mangling than C, so C++ is not
"ABI compatible" with C, but you can use the extern "C" feature to
interface with C.

For another example, the Mercury compiler's original back-end generates
code which uses a completely different calling convention than C,
but you can use Mercury's C interface features to interface with C.

> historically, very little effort has been put into
> maintaining that compatibility (beyond what is needed to interface the
> language runtime to the system), so it is not a thing to be relied on.

My experience is that when using a language other than C, lots of attention
gets paid to the C interface.  People are forever building bindings to C
libraries, because there are so many useful C libraries out there.
In other words, the C interface gets tested quite well.
It can indeed be relied on.

> I am not a priori opposed to reworking the *entire compiler* in a
> different language,

Doing that wouldn't eliminate the dependencies on the language's C
interface.  The C interface will still be needed, either in the source
code for GCC or in the other language's standard library or runtime
system, in order to access OS facilities which are defined with a C API.

I think the benefits of writing in an appropriate higher-level language 
can far outweigh the minor drawbacks that you identify.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]