|Wonder about design of a Java compiler firstname.lastname@example.org (malinda) (2004-12-29)|
|Re: Wonder about design of a Java compiler email@example.com (2004-12-30)|
|Re: Wonder about design of a Java compiler firstname.lastname@example.org (2005-01-03)|
|Date:||3 Jan 2005 00:53:51 -0500|
Writing a Java compiler is not a very difficult: Java is a
considerably simple language (compared to, say, C++), and can be
written following traditional compilation techniques.
In past, I've written a Java compiler when I was a college grad, to
expriment compiler implementation techniques I learned in our college
course: it took around 6 months to write a reasonably robust
implementation. The conventional lex->syntax->semantics->code-gen was
followed. You would need to refer the books The Java Language
Specification and The Java Virtual Machine Specification by the
original designers of Java from Sun.
Two main differences I noticed from conventional compilers and Java
The native code generation techniques (like register allocation) are
not useful in Java (but for a VM, and the file format is .class file,
with bytecodes; bytecode level is something like a (stack-based)
intermediate language you would use in a traditional compiler
implementation from which you would proceed to generate native code;
in Java compiler, you stop there).
Traditional, simple optimizations (like constant folding) can be done
in the compiler, but sophisticated optimizations cannot be done in
Java because of the restrictions imposed by the .class file format and
its close interaction/depenency with JVM.
Return to the
Search the comp.compilers archives again.