Re: Language used to write compilers

"Ira Baxter" <idbaxter@semdesigns.com>
31 Dec 2004 13:08:07 -0500

          From comp.compilers

Related articles
[5 earlier articles]
Re: Language used to write compilers dido@imperium.ph (Rafael 'Dido' Sevilla) (2004-12-30)
Re: Language used to write compilers nick.roberts@acm.org (Nick Roberts) (2004-12-30)
Re: Language used to write compilers samiam@moorecad.com (Scott Moore) (2004-12-31)
Re: Language used to write compilers Martin.Ward@durham.ac.uk (Martin Ward) (2004-12-31)
Re: Language used to write compilers nmm1@cus.cam.ac.uk (2004-12-31)
Re: Language used to write compilers nmm1@cus.cam.ac.uk (2004-12-31)
Re: Language used to write compilers idbaxter@semdesigns.com (Ira Baxter) (2004-12-31)
Re: Language used to write compilers Peter_Flass@Yahoo.com (Peter Flass) (2005-01-01)
Re: Language used to write compilers nmm1@cus.cam.ac.uk (2005-01-03)
Re: Language used to write compilers napi@cs.indiana.edu (2005-01-03)
Re: Language used to write compilers vbdis@aol.com (2005-01-09)
Re: Language used to write compilers nmm1@cus.cam.ac.uk (2005-01-12)
| List of all articles for this month |

From: "Ira Baxter" <idbaxter@semdesigns.com>
Newsgroups: comp.compilers
Date: 31 Dec 2004 13:08:07 -0500
Organization: http://extra.newsguy.com
References: 04-12-148
Keywords: practice
Posted-Date: 31 Dec 2004 13:08:07 EST

"Joe H." <joe_hesse@actcx.com> wrote in message
news:04-12-148@comp.compilers...


> I am thinking of taking a university course in compiler design. The
> instructor has chosen a book that teaches compiler implementation in
> Java. I always thought that compilers were usually written in C/C++.
>
> Question - what languages are used to write compilers? My world is
> Unix/Linux - should I wait until a course is offered using C/C++?
>
> [No. Compiler design is about algorithms and data structures, which
> are the same no matter what language you're using. And anyway, for
> most purposes Java is just C++ with some of the cruft stripped out and
> garbage collection added. The GC makes it a lot easier to whip up
> little sample programs. -John]


In fact, compilers are programs just like most other applications,
and you can technically code them in any reasonable language.


The real question at hand is, what does a language offer to a compiler
designer to enable him to produce compilers quickly and reliably? On
this front, C, Java, and all the general purpose languages fare pretty
badly, because their primitive abstractions are not the ones that
"compiler writers" want. Granted, you can build up a big set of
procedures to provide those, but that's a lot of work, and the
language still doesn't understand your intent.


A good language for a task is one which describes the tasks in terms
sensible for the task, and groks those terms. (This is called a
"domain specific language). BNF is such a nice language for
describing syntax.


Because compilers are a complex topic, it is unlikely that you can
find a "single" language that describes the task well.


We have taken an approach with our DMS Software Reengineering
Toolkit in what a set of languages helps a compiler
(well, source code analyzer/optimizer/translator) builder
can express his intent. It has "little" languages for:
    a) Syntax. Lexical and Grammatical.
    b) Analysis. (Attribute grammars).
    c) Optimization and Translation (Source-to-source rewrite rules).
                  A sublanguage describes side-effects on analysis results.
    d) General purpose computation (Parallel programming language).
Each of these languages has its own syntax and semantics.
More importantly, they enable concise specification of
the task at hand, and they allow the tools to analyze that
specification for errors, as well as building optimized
programs for the specific tasks.


So, you may learn how to build a compiler in a general purpose
language. You may also be forced to write one that way. But life can
be a lot easier if you use the right tool for the job :-}


--
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com


Post a followup to this message

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