|Using Functional Programming in C/C++ Compilers email@example.com (Kees & Annette van der Bent) (2000-04-03)|
|Re: Using Functional Programming in C/C++ Compilers firstname.lastname@example.org (2000-04-05)|
|Re: Using Functional Programming in C/C++ Compilers email@example.com (Dave MacQueen) (2000-04-05)|
|Re: Using Functional Programming in C/C++ Compilers firstname.lastname@example.org (Joachim Durchholz) (2000-04-14)|
|From:||email@example.com (Torben AEgidius Mogensen)|
|Date:||5 Apr 2000 22:25:26 -0400|
|Organization:||Department of Computer Science, U of Copenhagen|
Kees & Annette van der Bent <firstname.lastname@example.org> writes:
>Who is willing to share his/her opinions on using functional
>programming languages for developing C/C++ compilers/linkers/...?
>* What language(s) and why?
>* What part(s) best done in FP?
>* Combining FP language and C/C++?
>* Performance issues?
>* Sofware engineering issues (maintenance, teaching C/C++ developers, ...)
There is a tool called "ckit"
is basically a parser for C written in SML. The output is a
representation of the abstract syntac tree. If I was to write a C
compiler today, I would start from this.
SML has several features that makes it very well suited for writing
1) Recursive datatypes with pattern matching.
2) Automatic memory management (GC).
3) A good module system.
4) A type system that catches many errors at compile-time that would
not be caught at all by C.
6) A wide range of compilers, so you can develop on a fast compiler
and run your final code through an optimizing compiler.
You can see Andrew Appel's book "Modern Compiler Implementation in ML"
for examples of compiler-code written in SML. You can even compare
with how the same things are done in C or Java by also looking at
"Modern Compiler Implementation in C" and "Modern Compiler
Implementation in Java" by the same author.
As for maintenance, the module system and the type system are really
aids for maintenance. Most ML implementations have some kind of
intelligent recompilation scheme.
In all, the major problem may be social: C/C++ programmers may be
reluctant to learn a new (and radically different) language. The
language itself is fairly easy to learn (we teach it as the first
language at DIKU) but it takes a while for a programmer who thinks in
objects and state to wrap his mind around a different way of
Torben Mogensen (email@example.com)
Return to the
Search the comp.compilers archives again.