Running D in the Java VM

Paulo Pinto pjmlp at progtools.org
Fri Nov 15 11:15:18 PST 2013


Am 15.11.2013 19:39, schrieb Jeremy DeHaan:
> On Friday, 15 November 2013 at 14:41:32 UTC, Russel Winder wrote:
>> 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.
>
> It is a surprising amount of fun for me actually. I usually work on game
> development stuff(most currently DSFML), so it is a nice change of pace.
> It started as something that I thought could be production worthy, but
> who knows? Since for the long term I want this to only be used for
> Android compilation and not general Java VM stuff I was considering
> making use of version(Android) to separate things that are and aren't
> possible when going from D to Java.
>
> In any case, I'll keep working on it more as a knowledge/experience
> gaining project than anything else. So far it has been awesome at that
> for me. If it really starts to look good though I will see if I can get
> people to start using it. ;)

As info, Dalvik might go away in newer versions of Android following KitKat.

Google has a new backend that AOTs Java code, called ART. It is still 
developer quality though.

http://source.android.com/devices/tech/dalvik/art.html

http://readwrite.com/2013/11/07/google-says-it-could-replace-dalvik-runtime-in-next-version-of-android#awesm=~oni0ryCdWaEmK8

https://news.ycombinator.com/item?id=6655582

--
Paulo


More information about the Digitalmars-d-announce mailing list