[Mono-list] Re: Bootstrapping

Jonathan Pryor jonpryor@vt.edu
Thu, 08 Jul 2004 08:06:32 -0400

On Thu, 2004-07-08 at 01:03, Brandon Knitter wrote:
> The initial question still stands though.  How was the bootstrap compiler built.
>  I'll dig through the HISTORY and find it, its notes, and perhaps its source.

For C: http://cm.bell-labs.com/cm/cs/who/dmr/chist.html

I originally would have said that the first C compiler would be written
in PDP-7 assembly, which wouldn't be too unusual given that *lots* of
things were written in PDP-7 assembler.  (And for comparison, VAX
assembly has been compared to FORTRAN, so this isn't your typical
assembly.)  However, the above article makes it sound like C came from
the NB ("new B") compiler, which came from the B compiler, which...  One
of those compilers probably originated in an assembly program, but I
don't want to read the article that carefully now.

The Microsoft csc C# compiler is written in C++, so there are no
bootstrapping issues.

Mono's mcs C# compiler was written in C#, and originally compiled with
csc.  So csc was the original bootstrap compiler, but now a previous
version of the C# compiler is used.  For example, the Mono 0.97 compiler
could be used to compile the Mono 1.0 compiler.

PNET's C# compiler is written in C, so there are no bootstrapping

> Sorry to push this so far, but I really wanted to know why/how the bootstrapping
> required a download.  Why not just bootstrap from a K&R C-based program? ;-)

K&R C?!  Are you insane?  ANSI C89 at least.... :-D

The reason to require a download is very simple: minimize duplication of
resources.  If you wanted to bootstrap from a C program, you'd basically
need to write a C# compiler in C, in *addition* to the existing C#
compiler.  Maintaining two separate C# compilers is not a trivial task,
especially when you have More Important Things to do (JIT compiler,
class library, regression tests, bug fixing the C# compiler...).

So then you ask: why write the C# compiler in C#?  Elegance, to better
learn the C# language, and most importantly, because it's not C. ;-)

It also made a good test suite for the initial class library -- if mcs
couldn't compile itself, you broke the class library. :-)

Besides, between the Mono and PNET projects we've effectively done the
dual compiler scenario.  For a full "from source" bootstrap you'd just
need to get PNET's compiler to be able to process the Mono class
libraries.  This may already be possible, but I haven't tried it.

 - Jon