Running D in the Java VM

Russel Winder russel at winder.org.uk
Fri Nov 15 06:41:17 PST 2013


On Fri, 2013-11-15 at 08:13 +0100, Jeremy DeHaan wrote:
> Hey everyone!
> 
> I have been experimenting for the past couple of days with an 
> idea I had, and since I recently made a little progress I thought 
> I would share some of what I have been doing with you. What I 
> have done, in a nutshell, is began the process for a language 
> converter that takes D source files, converts them into Java 
> source files, and then compiles them as Java class files so that 
> they can be ran on Java's VM. It is extremely limited in what it 
> can do right now, only being able to convert/compile a simple 
> Hello World program, but I was proud of myself for getting even 
> that far so I wanted to brag. :P

Well done for having a go and getting somewhere with it, and hopefully
having some fun. However I am not sure this approach will lead to
anything that could go into general production. As others have pointed
out D → Java, source to source translation is probably not the best way
of getting D code to run on JVM. Scala, Groovy and Kotlin compile direct
to class files, i.e. generate JVM bytecode directly. Ceylon also
compiles to bytecode but not to class files. The point here is that Java
source cannot really encode much of the D semantics, whereas they can be
encoded in JVM bytecodes. Now that the JVM has method handles and
invokedynamic, the previous history of how to support non-Java code is
irrelevant: Scala's compilation strategy predates this JVM technology
and it shows; Java 8, Ceylon, Groovy, and Kotlin are using the new JVM
technology to great effect.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



More information about the Digitalmars-d-announce mailing list