Re: Bootstraping compilers ?

torbenm@app-4.diku.dk (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen)
Mon, 21 Apr 2008 10:35:52 +0200

          From comp.compilers

Related articles
[2 earlier articles]
Re: Bootstraping compilers ? roland.leissa@googlemail.com (=?ISO-8859-1?Q?Roland_Lei=DFa?=) (2008-04-18)
Re: Bootstraping compilers ? damian.thomas@unisys.com (Damian Thomas) (2008-04-18)
Re: Bootstraping compilers ? marcov@stack.nl (Marco van de Voort) (2008-04-18)
Re: Bootstraping compilers ? marcov@stack.nl (Marco van de Voort) (2008-04-18)
Re: Bootstraping compilers ? lindahl@pbm.com (Greg Lindahl) (2008-04-18)
Re: Bootstraping compilers ? cdb@nullstone.com (Christopher Glaeser) (2008-04-19)
Re: Bootstraping compilers ? torbenm@app-4.diku.dk (2008-04-21)
Re: Bootstraping compilers ? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-04-21)
Re: Bootstraping compilers ? pocm@soton.ac.uk (2008-04-22)
Re: Bootstraping compilers ? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-04-21)
Re: Bootstraping compilers ? spencer@panix.com (David Spencer) (2008-04-22)
Re: Bootstraping compilers ? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-04-22)
Re: Bootstraping compilers ? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-04-23)
[4 later articles]
| List of all articles for this month |
From: torbenm@app-4.diku.dk (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen)
Newsgroups: comp.compilers
Date: Mon, 21 Apr 2008 10:35:52 +0200
Organization: Department of Computer Science, University of Copenhagen
References: 08-04-059
Keywords: practice
Posted-Date: 21 Apr 2008 09:49:56 EDT

pocm@soton.ac.uk (Paulo Jorge de O. C. de Matos) writes:




> I am wondering if a compiler should always be able to compile
> itself. gcc for example seems to do it, but is this good practice or
> should this always happen?


When writing a compiler, it is more important to write it in a
language that is suitable for writing compilers than to write it in
the language that it compiles. Many languages are unsuited for
writing compilers, so by insisting on bootstrapping, you can make
things much more complicated than necessary.


If the language is new, you have more things to consider. FIrst of
all, the first implementation of the language (interpreter or
compiler) has to be made in a different language, though you can do
incremental bootstrapping, where you first implement a small subset of
the language in another language, then use this to bootstrap a
compiler for the same subset written in the subset, and then extend
the subset and compiler incrementally, bootstrapping after each step.


Eventually, either due to the above or due to language drift, where
you add new features to the language and the compiler, you are likely
to have your compiler be the only implementation of the full language,
so the only way to compile your compiler is to let it compile itself.
However, if you for some reason lose the compiled version of the
compiler (or it fails to run due to a system upgrade that breaks the
code), you are left with no way to compile your language other than
writing a new implementation to perform the bootstrap. It has
happened, so it is not a hypothetical situation.


For this reason, it is a good idea to write your compiler in a
language that you have third-party implementations of (and preferably
more than one), so you never get in the above situation.


Torben
[But it was so cool that they wrote Fortran H in itself. -John]



Post a followup to this message

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