[fpc-devel] Pascal to Java compiler

Michael Van Canneyt michael at freepascal.org
Thu Nov 27 22:43:37 CET 2008

On Thu, 27 Nov 2008, Marco van de Voort wrote:

> In our previous episode, Thaddy said:
> > I remember that the Delphi to java bytecode compiler isn't feature 
> > complete. I can't be: it will not be possible to compile any old delphi 
> > program into java byte code for several reasons. But it is possible to 
> > create Java bytecode with a - safe - subset of pascal syntax. It is also 
> > possible to use the same intermediate compiler to compile to .net/mono, 
> > though. It isn't possible to adapt Freepascal to write once compile 
> > anywhere with Java OR .Net. Both these assume restrictions that are 
> > simply not there in native code compilers, so you would have to work 
> > with one lame leg. I hope you realize that.
> Besides the pure language problem, there is also the library problem. Java
> and .NET are more than just a bytecode specification, there are also vast
> standard libraries, and the VCL-alike standard libraries of FPC (classes
> unit etc) are not designed to work on top of Java or .NET classes.
> So then you get a problem, what do you do? Keep it compatible with native,
> but a bit alien to the Java or .NET world, or re-spin the libraries in a
> more Java/.NET compatible way, building on top of the base libs. Also for
> this a lot of language extensions must be implemented that might not be
> elegantly back-portable to native, since their philosophies are not the
> same.
> But if you do such step, you introduce such a big barrier to actually
> switching between native and bytecode worlds (and probably between .NET and
> Java too) that one must ask what the benefit of long term keeping it in the
> same project really is. Since the native and bytecode targets basically then
> only share the base parser and semantic analysis.
> This friction probably lead to the demise of VCL.NET and shared source on
> the Borland side.
> As soon as you get the pure language part working, the users will fragment
> over mostly native and mostly bytecode oriented, and the common ground is
> gone.

Well, I think that the compiler could be shared between a native code
and bytecode machine. Jonas implemented something like it, so this part 
is possible.

- The RTL and class libraries would be totally different, since, as
  you correctly point out, the Java/.Net world have different philosphies.
  (no pointers, etc.)

  This is the main problem, as it requires a large effort.

- One should not attempt to implement Java or C# language constructs in


More information about the fpc-devel mailing list