From: | mw@ipx2.rz.uni-mannheim.de (Marc Wachowitz) |
Newsgroups: | comp.lang.java,comp.compilers |
Followup-To: | comp.lang.java,comp.compilers |
Date: | 30 Jan 1996 18:27:27 -0500 |
Organization: | --- |
References: | 96-01-037 96-01-089 96-01-109 |
Keywords: | C, translator |
David Hopwood (david.hopwood@lady-margaret-hall.oxford.ac.uk) wrote:
> Here is my estimation of how hard it would be to translate various languages
> to the JVM. YMMV.
[...]
> Impossible automatically:
> C, C++
Though I didn't ever read the C standard (and only parts of an earlier draft
of the C++ standard), in the light of what I've read from people who did, it
appears that there are generally too many assumptions about what a C program
can expect from its environment (and I even think there are many useful ones
which at least can be changed with reasonable effort not to expect too much,
particular with the help of a relatively "clean" implementation offering the
programmer good diagnostics about impurities instead of silent malfunction).
For example (as far as I know), pointers need only be meaningful within some
object (with a special case wrt. pointing directly after the end of arrays);
there's no requirement to map pointers to a large continuous memory area (as
the poor souls programming on segmented architectures know - but there their
problems have more to do with addressing objects exceeding the fixed segment
size, not so much the partitioning of the address space itself). I'd say the
task of implementing a completely standard conforming and useful C to JavaVM
translator isn't even conceptually very difficult, and a similar performance
as when compiling from Java source could be obtained with reasonable effort.
What would be more hard work is probably the creation of a reasonable inter-
face to the many libraries (particularly systems programming stuff like what
comes with Unix and variants) which typical C programs use. [I don't want to
speculate about C++, as I'm not sufficiently up to date wrt. the development
to guess about the complexity even for a C++ front-end, not to mention which
additional problems it would create for the back-end. Given that C++ was and
maybe sometimes still is also translated to C source code, it might be quite
possible - though the existing C++ to C code generation strategies might not
yield acceptable performance for a simple C to JavaVM translator, without an
additional knowledge about areas for improvement of certain patterns.]
------------------------------------------------------------------------------
Marc Wachowitz <mw@ipx2.rz.uni-mannheim.de>
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.