Re: Possible to write compiler to Java VM?

Darius Blasband <darius@phidani.be>
29 Jan 1996 17:47:51 -0500

          From comp.compilers

Related articles
[5 earlier articles]
Re: Possible to write compiler to Java VM? clodius@sst.lanl.gov (William Clodius) (1996-01-27)
Re: Possible to write compiler to Java VM? tdunbar@gserver.grads.vt.edu (Thomas Dunbar) (1996-01-27)
Re: Possible to write compiler to Java VM? tore@lis.pitt.edu (1996-01-27)
Re: Possible to write compiler to Java VM? sam@inf.enst.fr (Samuel Tardieu) (1996-01-28)
Re: Possible to write compiler to Java VM? hbaker@netcom.com (1996-01-29)
Re: Possible to write compiler to Java VM? david.hopwood@lady-margaret-hall.oxford.ac.uk (1996-01-29)
Re: Possible to write compiler to Java VM? darius@phidani.be (Darius Blasband) (1996-01-29)
Re: Possible to write compiler to Java VM? stt@copperfield.camb.inmet.com (1996-01-29)
Re: Possible to write compiler to Java VM? ncohen@watson.ibm.com (1996-01-29)
Re: Possible to write compiler to Java VM? RLS@psu.edu (1996-01-30)
Re: Possible to write compiler to Java VM? mg@asp.camb.inmet.com (1996-01-30)
Re: Possible to write compiler to Java VM? jeff@uh.edu (Jeff M Younker) (1996-01-30)
Re: Possible to write compiler to Java VM? mw@ipx2.rz.uni-mannheim.de (1996-01-30)
[16 later articles]
| List of all articles for this month |

From: Darius Blasband <darius@phidani.be>
Newsgroups: comp.compilers
Date: 29 Jan 1996 17:47:51 -0500
Organization: EUnet Belgium, Leuven, Belgium
References: 96-01-037, 96-01-061
Keywords: translator, interpreter, comment

>The easiest way to compile a programming language to the Java VM is to
>cross-compile to Java and use the Java compiler to generate Java VM code.
>So you don't need to know the details of the Java VM and you can use all
>the features of Java like garbage collection and libraries. But you need
>to know Java implementation in some detail to make design decisions like
>using implicitely Javas internal stack or using a stack explicitely and
>things like that.


I am afraid I basically disagree with you: generating Java source code
as intermediate compilation step does not seem to be an applicable
(not to mention good) idea in almost any case I can think of. Fortran
to Java ? Cobol to Java ? Perl to Java ? Translating such languages
to Java source code will prove pretty cumbersome, classes will have to
be designed for almost every syntactical construct of the source
language, the resulting performance will be poor (How do you translate
Cobol's PERFORM THRU into Java source code ?)


Some other languages will even prove worse. Prolog to Java ? Lisp to
Java ? The peculiarities of these languages's control flow mechanism
will prove even more difficult to translate into Java (at least at the
source level, I am not even sure it would be reasonable to do so at
the VM level)


The solution you suggest will only work when the language you wish to
compile is pretty close to the Java model, and in these case,
generating bytecode directly is pretty easy. There is an almost
functional mapping between the primitives of the language you wish to
compile and the Java VM.


In all other cases, my guess (IMHO) would be that it would require
more skill to know how Java generates VM code and generate Java source
code accordingly, than to generate VM code directly.


Please don't misunderstand me: I am pretty enthousiast about using
medium-level languages as intermediate steps to compile higher-level
languages. However, I believe that Java is definitely not a good
candidate for such a purpose, specially when considering the very wide
range (in terms of paradigms, control flow system, type systems,
etc...) of languages some people plan to compile to the Java VM.


Darius.
[I wonder how many bugs in Java VM implementations will surface when
people start generating code from non-Java sources. -John]
--


Post a followup to this message

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