Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Compiler design in C? Date: Wed, 09 Nov 2016 13:25:55 -0800 Organization: None to speak of Lines: 53 Message-ID: References: <0915fef9-bb57-48b7-b98a-342f0e5ee39f@googlegroups.com> <87shr14n5b.fsf@gmail.com> <0c4c02d2-69b2-4601-a1b1-15310fe20fe4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="468e487b6e5a4801c5b49cc535d42bc5"; logging-data="15485"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2T3rOwiFVoD65G9TlvnlV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:7zN4Di8rlrw5ANUOziwtYsxzW4Y= sha1:ovpzSo6uN6srgIfT5yIrIN5WcSc= Xref: csiph.com comp.lang.c:96228 David Brown writes: > On 09/11/16 12:15, Thiago Adams wrote: >> On Wednesday, November 9, 2016 at 8:30:41 AM UTC-2, David Brown >> wrote: >>> On 08/11/16 23:33, Gareth Owen wrote: >>>> jacobnavia writes: >>>> >>>>> Le 08/11/2016 à 21:12, David Brown a écrit : >>>>> >>>>>> C++ is the obvious choice if you want a fast compiler. >>>>> >>>>> What? >>>>> >>>>> It is incredible the things that C++ heads will tell people? A >>>>> c++ compiler is incredibly slow. lcc-win is 4 or 5 times faster >>>>> than gcc even when gcc is just compiling C. [...] > Yes, this is perfectly natural. In the same way, a bicycle factory > should use bicycles to deliver new bicycles to bicycle shops, and car > factories should use cars to transport new cars around. > > In other words, it is complete bollocks. > > It might be a fun experiment to write your compiler in its own language, > but you should write your compiler in the best language for writing such > compilers. It's hardly *complete* bollocks. Certainly there are advantages in choosing the best implementation language for a compiler, and all else being equal you should choose the language that is best for that task. Using the same language as the one you're compiling for doesn't give you much *direct* advantage. On the other hand, if the target language is suitable for use in writing a compiler there are some real advantages in self-hosting. Say you're using language X to write a compiler for language Y. If X==Y, then improvements in the speed of the generated code translate to improvements in compile time speed as soon as you recompile. And if you're implementing a compiler for a *new* language, one that you're redefining as you implement it, then writing a compiler in it can give you a lot of experience in actually using it. (I once heard about a COBOL compiler written in COBOL. Not the choice I would have made, but apparently it worked pretty well.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"