|[3 earlier articles]|
|Re: Java compiler courses email@example.com (glen herrmannsfeldt) (2007-04-23)|
|Re: Java compiler courses DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-04-23)|
|Re: Java compiler courses firstname.lastname@example.org (Chris Dollin) (2007-04-23)|
|Re: Java compiler courses email@example.com (Karsten Nyblad) (2007-04-25)|
|Re: Java compiler courses firstname.lastname@example.org (wooks) (2007-04-25)|
|Re: Java compiler courses DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-04-25)|
|Re: Java compiler courses email@example.com (2007-04-26)|
|Re: Java compiler courses firstname.lastname@example.org (Michael Klemm) (2007-04-26)|
|Re: Java compiler courses email@example.com (George Neuner) (2007-04-26)|
|Re: Java compiler courses firstname.lastname@example.org (glen herrmannsfeldt) (2007-04-26)|
|Re: Java compiler courses cfc@shell01.TheWorld.com (Chris F Clark) (2007-04-26)|
|Language features for compiler writing was: Java compiler courses cfc@shell01.TheWorld.com (Chris F Clark) (2007-04-27)|
|Re: Java compiler courses DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-04-27)|
|[18 later articles]|
|From:||email@example.com (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen)|
|Date:||26 Apr 2007 09:37:11 -0400|
|Organization:||Department of Computer Science, University of Copenhagen|
|Posted-Date:||26 Apr 2007 09:37:11 EDT|
Hans-Peter Diettrich <DrDiettrich1@aol.com> writes:
> wooks wrote:
>> Why would anybody want to write a compiler in Java (unless it's the
>> only language they know).
> What should the students learn: writing compilers in C, or writing
> compilers in general?
C is a horrible language for writing compilers due to bad
infrastructure for tree and list structures (i.e., GC, polymorphism
and pattern matching). C++ has polymorphism (through templates), but
still lacks GC and pattern matching. Java has GC, newer versions also
have polymorphism, but it still lacks pattern matching. ML (several
variants including SML, OCaml and F#), Haskell and even Prolog are
better choices as all these have GC, polymorphism and pattern
> While speed may be an argument in an commercial compiler, a compiler
> course should spot the principles of an compiler, not the details.
I fully agree. So choose an infrastructure (language etc.) that
supports these principles without requiring you to take care of a lot
of details (such as GC, bounded datastructures, low-level building and
inspection of data structures, etc.).
> A modular OO approach, as required by Java, IMO is a good starting
> point for every big project.
Modular, yes. OO, maybe. I have yet to see any major benefits OO
gives you in compiler writing that you can't get through polymorphism
and ML-style modules. And ML-style datatstructres are (IMO) much
easier than objects for representing syntax trees etc.
[I entirely agree. Data structures and pattern matching are really useful,
OOP isn't for writing compilers. So I write stuff in perl. -John]
Return to the
Search the comp.compilers archives again.