Related articles |
---|
'Learning Compilers': Functional vs. Imperative Host? jswitte@spam.bloomington.in.us (Jim Witte) (2004-03-19) |
Re: 'Learning Compilers': Functional vs. Imperative Host? torbenm@diku.dk (2004-03-26) |
Re: 'Learning Compilers': Functional vs. Imperative Host? jswitte@bloomington.in.us (Jim Witte) (2004-04-03) |
Re: 'Learning Compilers': Functional vs. Imperative Host? jswitte@bloomington.in.us (Jim Witte) (2004-04-03) |
Re: 'Learning Compilers': Functional vs. Imperative Host? jswitte@bloomington.in.us (Jim Witte) (2004-04-03) |
From: | torbenm@diku.dk (Torben Ęgidius Mogensen) |
Newsgroups: | comp.compilers |
Date: | 26 Mar 2004 22:03:34 -0500 |
Organization: | Department of Computer Science, University of Copenhagen |
References: | 04-03-070 |
Keywords: | functional, courses |
Posted-Date: | 26 Mar 2004 22:03:34 EST |
Jim Witte <jswitte@spam.bloomington.in.us> writes:
> I'm taking CS at Indiana
> University Bloomington, where the 2-course compiler sequence is *very*
> heavily tilted toward writing compilers in Scheme, both as the
> "source" language that is to be compiled, and the host in which the
> compiler is written.
>
> But I also get the feeling (although I haven't actually taken the
> compilers courses) that we never actually learn how to use "standard"
> parsing tools such as lexx and yacc, which I would think would be nice
> to know if you're going to write compilers in a host other than
> Scheme..
>
> Is there a general consensus on which host language is better for a
> compiler to be written in?
People who have tried writing compilers both in languages with and
without GC are almost universally in agreement that GC is a big
advantage. As we go further, the agreement decreases, but people who
use more than one kind of language tend to prefer functional languages
(or possibly Prolog-like languages) as allocation of and walking over
data structures is much more convenient in these languages than in
imperative or OO languages. In particular ML-like languages with
pattern-matching on data structures make it easy to work on abstract
syntax trees.
As for lexing and parsing, that can be separated quite cleanly from
code-generation and other processing of abstract syntax trees. Using
Scheme, Prolog or another language with a built-in parser for data
structures allows you to read abstract syntax directly from input, so
you can skip lexing and parsing. I think lexing and parsing needs to
be taught somewhere in an undergraduate curriculum (as it is useful
for much more than compilers), but it doesn't have to be in the
compiler course(s) (though it should preferably be no later than
this).
Torben
Return to the
comp.compilers page.
Search the
comp.compilers archives again.