Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1437

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end
From "BartC" <bc@freeuk.com>
Newsgroups comp.compilers
Subject Re: self-hosting, was Writing A Plain English Compiler
Date Tue, 11 Nov 2014 23:33:12 -0000
Organization virginmedia.com
Lines 58
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <14-11-029@comp.compilers> (permalink)
References <14-11-004@comp.compilers> <14-11-005@comp.compilers> <14-11-007@comp.compilers> <14-11-014@comp.compilers> <14-11-016@comp.compilers> <14-11-020@comp.compilers> <14-11-028@comp.compilers>
NNTP-Posting-Host news.iecc.com
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding 8bit
X-Trace miucha.iecc.com 1415765867 2125 2001:470:1f07:1126:0:676f:7373:6970 (12 Nov 2014 04:17:47 GMT)
X-Complaints-To abuse@iecc.com
NNTP-Posting-Date Wed, 12 Nov 2014 04:17:47 +0000 (UTC)
Keywords debug, practice, comment
Posted-Date 11 Nov 2014 23:17:47 EST
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
Xref csiph.com comp.compilers:1437

Show key headers only | View raw


"Richard Hable" <portempa@aon.at> wrote in message
> On 11/09/14 02:16, BartC wrote:
>
>> Self-hosting (implementing a language in itself) is a nice touch, but
>> I don't think it's that important, perhaps because people are
>> realising that the best language to implement a compiler in, is not
>> necessarily the language that is being compiled. Unless of course you
>> are trying to use a single language for everything.)
>
> I think, the main advantage of self-hosting is that it can be used as
> one big unit test: you can compile the compiler with itself, use the
> resulting compiler to compile itself again, and check if the result is
> exactly the same.

Yes, that's partly what I do, because I don't have any substantial
non-compiler, non-language and non-development related applications to try
different versions on.

It does, however, run into problems, such as frequently ending up with
non-working compilers and/or support programs, and with most of the bridges
burnt! Then recovering can be tricky.

It is possible to compile a compiler with itself, and perhaps even repeat
that again, but still end up with something that apparently still works, but
has now developed a bug. Perhaps because it affects some code that is not
executed in the compiler, because the particular language construct to
invoke the bug doesn't occur in the compiler source.

(My setup is a bit awkward to describe, but:

I have an interpreted language M that compiles to bytecode. Its compiler is
written in M.

I have a statically typed language B that compiles to native code. Its
compiler is also written in M.

To run any M bytecode programs, I use an interpreter written in B. So there
are a few cyclic dependencies and you can imagine the fun and games when
some subtle bug gets past or I skimp on testing when I make changes. The bug
can be in either compiler (or in the generated bytecode or native code), or
in the interpreter.

To help out however, I also maintain a version of the interpreter written in
C. (Or near enough C, as I use a slightly different syntax, put through a
simple translator, to end up as proper C. That translator is written in
M...)

BTW if anyone is wondering how well an interpreted compiler performs, this
one can compile itself in about 1.3 seconds on a low-end PC. But it's
divided into modules and the biggest one takes about 1/6th second to
compile. The whole thing isn't very big, about 20Kloc, so the compiled
lines-per-second isn't great, but it's not a problem at the minute.)

--
Bartc
[It's time to reread Ken Thompson's Turing award lecture,
available here: http://cm.bell-labs.com/who/ken/trust.html
-John]

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-04 15:50 -0600
  Re: Writing A Plain English Compiler Joshua Cranmer 🐧 <Pidgeot18@verizon.net> - 2014-11-05 00:54 -0600
    Re: Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-06 18:52 -0600
      Re: Writing A Plain English Compiler Joshua Cranmer 🐧 <Pidgeot18@verizon.net> - 2014-11-07 22:54 -0600
        Re: Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-08 02:41 -0600
        Re: Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-08 03:46 -0600
          Re: Writing A Plain English Compiler "BartC" <bc@freeuk.com> - 2014-11-09 01:16 +0000
            Re: Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-10 14:37 -0600
            Re: self-hosting, was Writing A Plain English Compiler Richard Hable <portempa@aon.at> - 2014-11-11 19:50 +0100
              Re: self-hosting, was Writing A Plain English Compiler "BartC" <bc@freeuk.com> - 2014-11-11 23:33 +0000
                Re: self-hosting, was Writing A Plain English Compiler anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-11-12 08:46 +0000
                Re: self-hosting, was Writing A Plain English Compiler "BartC" <bc@freeuk.com> - 2014-11-12 11:15 +0000
              Re: self-hosting, was Writing A Plain English Compiler anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-11-12 08:40 +0000
    Re: Writing A Plain English Compiler "BartC" <bcas@freeuk.com> - 2014-11-07 11:36 +0000
    Re: Writing A Plain English Compiler George Neuner <gneuner2@comcast.net> - 2014-11-07 16:23 -0500
      Re: Writing A Plain English Compiler Richard Hable <portempa@aon.at> - 2014-11-08 17:22 +0100
      Re: Writing A Plain English Compiler Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-11-08 10:48 -0600
        Re: language design models, was Writing A Plain English Compiler George Neuner <gneuner2@comcast.net> - 2014-11-09 14:30 -0500
          Re: language design models, was Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-10 03:29 -0600
          Re: Writing A Plain English Compiler Tomasz Kowaltowski <tk@ic.unicamp.br> - 2014-11-10 09:13 -0200
            Re: Writing A Plain English Compiler "Gerry Rzeppa" <gerry.rzeppa@pobox.com> - 2014-11-10 17:19 -0600
      Re: matching tasks to languages, was Writing A Plain English Compiler Gene Wirchenko <genew@telus.net> - 2014-11-10 15:37 -0800
    Re: Writing A Plain English Compiler Martin Ward <martin@gkc.org.uk> - 2014-11-10 22:56 +0000
  Re: Writing A Plain English Compiler "BartC" <bcas@freeuk.com> - 2014-11-07 11:39 +0000
    Re: Writing A Plain English Compiler "BartC" <bc@freeuk.com> - 2014-11-08 00:35 +0000
  Fundamentals for a Compiler and Language (was: Writing A Plain English Compiler) federation2005@netzero.com - 2014-12-29 13:30 -0800

csiph-web