Re: Using Functional Programming in C/C++ Compilers

Dave MacQueen <>
5 Apr 2000 22:41:24 -0400

          From comp.compilers

Related articles
Using Functional Programming in C/C++ Compilers (Kees & Annette van der Bent) (2000-04-03)
Re: Using Functional Programming in C/C++ Compilers (2000-04-05)
Re: Using Functional Programming in C/C++ Compilers (Dave MacQueen) (2000-04-05)
Re: Using Functional Programming in C/C++ Compilers (Joachim Durchholz) (2000-04-14)
| List of all articles for this month |

From: Dave MacQueen <>
Newsgroups: comp.compilers
Date: 5 Apr 2000 22:41:24 -0400
Organization: Compilers Central
References: 00-04-036
Keywords: functional

Kees & Annette van der Bent <> 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?

ML (Standard ML in particular) has a good track record in compiler
applications. Compiling is basically a symbolic process, and SML is
an excellent symbolic processing language. See the compiler projects
list at


for examples.

> * What part(s) best done in FP?

Every aspect of compiling is suitable for implementation in ML.

> * Combining FP language and C/C++?

ML compilers generally have a C foreign function interface. SML/NJ
has a basic one now, and will have a better IDL-based one in the next

> * Performance issues?

Functional language implementations will typically take more space,
but the time penalty can be modest to non-existent. [It's not easy to
demonstrate this, since I don't know of any algorithmicly equivalent
compilers written in ML and, say, C that can be usefully compared.]

> * Sofware engineering issues (maintenance, teaching C/C++ developers, ...)

SML has many features that make it attractive from a software
engineering point of view: safety, sound static typing, polymorphism,
algebraic types and pattern matching, a powerful module system with
parametric modules, exceptions, concurrency, garbage collection, etc.
SML/NJ has a very helpful compilation manager, CM, that helps minimize
development turn-around time.

SML programs do not, can not, dump core.

> * ...
> * References?

See the links to compiler projects given above. Also see Andrew
Appel's "Modern Compiler Implementation in ML" (and compare the code
samples available in ML, C and Java).


Also see these two very useful compiler related tools available with
the SML/NJ system.

1. ckit, an ansci C front end producing typed abstract syntax


ckit 1.0 was released 31 March 2000. It has been used as the front
end for various C static analysis tools in an industrial context where
millions of lines of code are being analyzed, and it has been used in
another industrial application as the front end for a C-derived domain
specific language.

2. MLRISC, a code generation framework


MLRISC is used in the SML/NJ compiler and in several other compiler
projects. Back ends are currently provided for x86, sparc, alpha,
powerpc, hppa.

Dave MacQueen
Room 2C-480, Bell Labs, 600 Mountain Ave, Murray Hill, NJ 07974

Post a followup to this message

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