Re: self-hosting, was Writing A Plain English Compiler

"BartC" <>
Wed, 12 Nov 2014 11:15:21 -0000

          From comp.compilers

Related articles
[4 earlier articles]
Re: Writing A Plain English Compiler (Gerry Rzeppa) (2014-11-08)
Re: Writing A Plain English Compiler (BartC) (2014-11-09)
Re: self-hosting, was Writing A Plain English Compiler (Richard Hable) (2014-11-11)
Re: self-hosting, was Writing A Plain English Compiler (BartC) (2014-11-11)
Re: self-hosting, was Writing A Plain English Compiler (2014-11-12)
Re: self-hosting, was Writing A Plain English Compiler (2014-11-12)
Re: self-hosting, was Writing A Plain English Compiler (BartC) (2014-11-12)
| List of all articles for this month |

From: "BartC" <>
Newsgroups: comp.compilers
Date: Wed, 12 Nov 2014 11:15:21 -0000
References: 14-11-004 14-11-005 14-11-007 14-11-014 14-11-016 14-11-020 14-11-028 14-11-029 14-11-031
Keywords: debug, practice, comment
Posted-Date: 12 Nov 2014 21:43:57 EST

"Anton Ertl" <> wrote in message
> "BartC" <> writes:
>>It does, however, run into problems, such as frequently ending up with
>>non-working compilers and/or support programs, and with most of the
>>burnt! Then recovering can be tricky.
> To deal with that, you have a "stable" and executable (or buildable)
> version somewhere, and make sure that your compiler builds with that
> version. So if the current version no longer builds with itself, you
> build it with the stable version; for that you also need a simple way
> to switch from building with the current version (default) to building
> with the stable version.

There are still problems, especially with on-going development of a language
and its compiler.

For example, you make an enhancement in the language. The compiler source is
modified, and the change is tested and it works. Then you decide to make use
of the new feature in the compiler code.

The problem comes when something else doesn't work and you need to revert
back, but those old binaries will not support the new feature that now
litters the compiler sources!

In the case of bytecode languages, there is a more specific problem: the
bytecode format could be modified in such a way that new binary bytecode
files will be incompatible with both old bytecode files, and with the
interpreter used. (This might be as simple as adding a new bytecode

Now, with a self-hosting system where all the support programs (the
compiler, any loader (a program that does a similar job to a linker but for
bytecode), libraries, and even IDEs and editors) will all be using version
X, and the interpreter runs only version X, everything needs to be switched
over to version Y. But everything can't be done simultaneously, so it gets
messy (with X-X, X-Y, and Y-Y versions being involved).

Without self-hosting and using external tools maintained by someone else,
most of these headaches would disappear. (I do it because I like the
satisfaction of being independent.)

"Anton Ertl" <> wrote in message

> Another reason to self-host a compiler is the signal it sends: If you
> claim that your language is general-purpose, and you write the
> compiler for it in a different language, you are obviously not very
> convinced of the capabilities of your language, so why should anybody
> else use it?

Sometimes you have to use a different language to get started. Or you may be
modifying a compiler which is in another language (perhaps one of yours) to
compile a new language, and it would be silly to rewrite it in the new
language just for the purpose of being able to say it's self-hosted.

Another problem with self-hosting is distributing the program so that
someone else can use it. But is that done as a binary executable, or as

With source-code in a new language, no-one will yet have a working binary
compiler to build it! While binary distributions have all the usual problems
(of supporting multiple platforms and getting people to trust it).

(If I was distributing a new language compiler, it would likely be in the
form of a single C source file. However, because my compilers aren't written
in C, and are interpreted, that single file would actually be the
interpreter, plus the compiler bytecode represented as data within the C

[That's fine -- tools like bison are written in themselves, but they
distribute enough C code to bootstrap it. -John]

Post a followup to this message

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