[Mono-list] Novel Proposal for Mono Compiler Implementations

Bob Salita Bob_Salita@SoftworksLtd.com
Tue, 10 Jul 2001 18:51:26 -0500

Novel may be too strong a word but certainly a shift in thinking about 
compiler implementation is accurate. I propose a different kind of compiler 
design for Mono. One that gives significantly more utility to the compiler, 
and a compelling distinction between Mono and Microsoft's compiler 
implementations. One that is ideally suited to the open source philosophy.

State of the Art
Having spent quite a few years thinking about compilers and virtual machine 
technology, it occurred to me that our view of compilers is obsolete. 
Current compilers read source code and emit machine code, or bytecodes. This 
is the traditional monolithic approach.

The Problem
When new execution environments are invented, such as in .Net, Java VM or 
AMD's SledgeHammer, monolithic compilers are difficult to adapt. This is 
because the compiler's emitter has a fixed target, either IL or bytecodes or 
native code. This is too inflexible.

The Solution
Instead, compilers should NOT emit IL, bytecodes, or even native code. They 
should emit NOTHING. Their task is to merely translate source code into 
information rich parsetrees. Once the parsetrees are built, the compiler's 
work is done.

Next a user selectable emitter traverses the parsetrees (sort of like 
traversing XML DOM structures). The emitter outputs any of a multitude of 
targets. The targets could be IL, bytecodes, native code, XML, obfuscated 
code, lint messages, documentation, or even other languages (e.g. VB6 
compiler builds a parsetree, emitter outputs C#).

The benefits are obvious. Combinations of compiler and emitters still 
produce traditional code. Nothing changes there. The compiler becomes much 
simpler to write and the emitters are even simpler. First year programmers 
will be able to write emitters that effectively generate code for whole new 
architectures. Emitter technology would be highly reusable between disparate 
compiler implementations or languages. Call it Open Compiler Technology.

Contrast this solution to our current discussions about the vexing problem 
of adapting gcc to .Net. Or the discussions about how to take existing 
useful Java applications and them in Mono. Open Compiler Technology makes 
these discussions moot because the solution and implementation method are 

I propose that Open Compiler Technology be the architecture of compilers 
used in Mono, furthermore we should demand this style of compiler 
architecture from all our compiler vendors. The benefits of an Open Compiler 
are unlike any that we have experienced.


Get your FREE download of MSN Explorer at http://explorer.msn.com