Jump to page: 1 24  
Page
Thread overview
Running D in the Java VM
Nov 15, 2013
Jeremy DeHaan
Nov 15, 2013
Timur Gafarov
Nov 15, 2013
Jeremy DeHaan
Nov 15, 2013
Rory McGuire
Nov 15, 2013
Jeremy DeHaan
Nov 15, 2013
Paulo Pinto
Nov 15, 2013
John Colvin
Nov 15, 2013
Rory McGuire
Nov 15, 2013
Kai Nacke
Nov 15, 2013
Paulo Pinto
Nov 15, 2013
Russel Winder
Nov 15, 2013
Russel Winder
Nov 15, 2013
Jeremy DeHaan
Nov 15, 2013
Paulo Pinto
Nov 16, 2013
Dejan Lekic
Nov 17, 2013
John J
Nov 20, 2013
Jeremy DeHaan
Nov 21, 2013
Volcz
Nov 21, 2013
John J
Nov 21, 2013
Paulo Pinto
Nov 21, 2013
inout
Nov 21, 2013
Paulo Pinto
Nov 21, 2013
inout
Nov 21, 2013
Paulo Pinto
Nov 21, 2013
John J
Nov 22, 2013
Paulo Pinto
Nov 22, 2013
eles
Nov 22, 2013
Paulo Pinto
Nov 22, 2013
Jacob Carlborg
Nov 22, 2013
Paulo Pinto
Nov 22, 2013
John Colvin
Nov 22, 2013
Paulo Pinto
Nov 23, 2013
Rémy Mouëza
November 15, 2013
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

You may want to ask, "Hey, man. D is a great language. Why would I ever want to convert it to Java?" Normally, you wouldn't. Java blows. What I am envisioning for this project is something quite magical in my opinion. If we can take D code and have it compile into Java class files, we can then compile them into Android dex files. This would make D able to build and run on Android devices through its VM. Sure, people are working on getting D to compile to ARM binaries, but this could be another option as a Java alternative on Android.(eventually)

Unfortunately I do not know much about compilers, but even in the last couple of days I feel like I have learned a great deal about what kinds of stuff goes into them. Eventually I'd like to make a full blown compiler that takes D code and can go right to dex files, but that would be something that would happen way down the road. In order to get D working on Android sooner, I figured a language converter would be the easier route.

I can, and would love to go in to more detail about this, but it is getting late and this post is already quite long. Maybe I should start a blog about my D escapades? Anyways, I would love to hear feedback on this idea! Thanks for your time!
November 15, 2013
15.11.2013 10:13, Jeremy DeHaan пишет:
> 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
>
> You may want to ask, "Hey, man. D is a great language. Why would I ever
> want to convert it to Java?" Normally, you wouldn't. Java blows. What I
> am envisioning for this project is something quite magical in my
> opinion. If we can take D code and have it compile into Java class
> files, we can then compile them into Android dex files. This would make
> D able to build and run on Android devices through its VM. Sure, people
> are working on getting D to compile to ARM binaries, but this could be
> another option as a Java alternative on Android.(eventually)
>
> Unfortunately I do not know much about compilers, but even in the last
> couple of days I feel like I have learned a great deal about what kinds
> of stuff goes into them. Eventually I'd like to make a full blown
> compiler that takes D code and can go right to dex files, but that would
> be something that would happen way down the road. In order to get D
> working on Android sooner, I figured a language converter would be the
> easier route.
>
> I can, and would love to go in to more detail about this, but it is
> getting late and this post is already quite long. Maybe I should start a
> blog about my D escapades? Anyways, I would love to hear feedback on
> this idea! Thanks for your time!

Maybe it would be better to compile D directly into JVM/Dalvik bytecode?
November 15, 2013
On Fri, Nov 15, 2013 at 9:13 AM, Jeremy DeHaan <dehaan.jeremiah@gmail.com>wrote:

>
> I can, and would love to go in to more detail about this, but it is getting late and this post is already quite long. Maybe I should start a blog about my D escapades? Anyways, I would love to hear feedback on this idea! Thanks for your time!
>

Nice one, I have to use Java at work, it would be awesome if I didn't have
to.
Would be cool if you make it so that the outputs to java are just trasforms
of the AST that way people could write other types of output such as C.


November 15, 2013
On Friday, 15 November 2013 at 07:30:07 UTC, Timur Gafarov wrote:
>
> Maybe it would be better to compile D directly into JVM/Dalvik bytecode?

Oh, absolutely. Like I said though, I don't really know that much about compilers so I decided to go this route. Also, it's actually been a pretty fun project so far and I see no reason to do it a different way right now.

November 15, 2013
On Friday, 15 November 2013 at 07:13:34 UTC, 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
>
> You may want to ask, "Hey, man. D is a great language. Why would I ever want to convert it to Java?" Normally, you wouldn't. Java blows. What I am envisioning for this project is something quite magical in my opinion. If we can take D code and have it compile into Java class files, we can then compile them into Android dex files. This would make D able to build and run on Android devices through its VM. Sure, people are working on getting D to compile to ARM binaries, but this could be another option as a Java alternative on Android.(eventually)
>
> Unfortunately I do not know much about compilers, but even in the last couple of days I feel like I have learned a great deal about what kinds of stuff goes into them. Eventually I'd like to make a full blown compiler that takes D code and can go right to dex files, but that would be something that would happen way down the road. In order to get D working on Android sooner, I figured a language converter would be the easier route.
>
> I can, and would love to go in to more detail about this, but it is getting late and this post is already quite long. Maybe I should start a blog about my D escapades? Anyways, I would love to hear feedback on this idea! Thanks for your time!

It is an impossible task, because many of the D semantics cannot be expressed in JVM/Dalvik bytecode.

--
Paulo
November 15, 2013
On Friday, 15 November 2013 at 08:50:14 UTC, Paulo Pinto wrote:
> On Friday, 15 November 2013 at 07:13:34 UTC, 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
>>
>> You may want to ask, "Hey, man. D is a great language. Why would I ever want to convert it to Java?" Normally, you wouldn't. Java blows. What I am envisioning for this project is something quite magical in my opinion. If we can take D code and have it compile into Java class files, we can then compile them into Android dex files. This would make D able to build and run on Android devices through its VM. Sure, people are working on getting D to compile to ARM binaries, but this could be another option as a Java alternative on Android.(eventually)
>>
>> Unfortunately I do not know much about compilers, but even in the last couple of days I feel like I have learned a great deal about what kinds of stuff goes into them. Eventually I'd like to make a full blown compiler that takes D code and can go right to dex files, but that would be something that would happen way down the road. In order to get D working on Android sooner, I figured a language converter would be the easier route.
>>
>> I can, and would love to go in to more detail about this, but it is getting late and this post is already quite long. Maybe I should start a blog about my D escapades? Anyways, I would love to hear feedback on this idea! Thanks for your time!
>
> It is an impossible task, because many of the D semantics cannot be expressed in JVM/Dalvik bytecode.
>
> --
> Paulo

Like what? Barring low-level device access, they are both turing complete languages and given the necessary transformations a complete program in one can always be statically* translated to the one in the other. However, efficient java code would be a different matter.

*very important. There are many code-level concepts in D that are not expressible in the JVM, but a static translation doesn't need to honor those: it simply needs to make a program that has the same observable effects for any given input. This is definitely possible, although quite possibly monstrously involved when done in detail.
November 15, 2013
Surely the main requirements would be gui and networking? Which would be
completely possible.
 On 15 Nov 2013 12:05, "John Colvin" <john.loughran.colvin@gmail.com> wrote:

> On Friday, 15 November 2013 at 08:50:14 UTC, Paulo Pinto wrote:
>
>> On Friday, 15 November 2013 at 07:13:34 UTC, 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
>>>
>>> You may want to ask, "Hey, man. D is a great language. Why would I ever want to convert it to Java?" Normally, you wouldn't. Java blows. What I am envisioning for this project is something quite magical in my opinion. If we can take D code and have it compile into Java class files, we can then compile them into Android dex files. This would make D able to build and run on Android devices through its VM. Sure, people are working on getting D to compile to ARM binaries, but this could be another option as a Java alternative on Android.(eventually)
>>>
>>> Unfortunately I do not know much about compilers, but even in the last couple of days I feel like I have learned a great deal about what kinds of stuff goes into them. Eventually I'd like to make a full blown compiler that takes D code and can go right to dex files, but that would be something that would happen way down the road. In order to get D working on Android sooner, I figured a language converter would be the easier route.
>>>
>>> I can, and would love to go in to more detail about this, but it is getting late and this post is already quite long. Maybe I should start a blog about my D escapades? Anyways, I would love to hear feedback on this idea! Thanks for your time!
>>>
>>
>> It is an impossible task, because many of the D semantics cannot be expressed in JVM/Dalvik bytecode.
>>
>> --
>> Paulo
>>
>
> Like what? Barring low-level device access, they are both turing complete languages and given the necessary transformations a complete program in one can always be statically* translated to the one in the other. However, efficient java code would be a different matter.
>
> *very important. There are many code-level concepts in D that are not expressible in the JVM, but a static translation doesn't need to honor those: it simply needs to make a program that has the same observable effects for any given input. This is definitely possible, although quite possibly monstrously involved when done in detail.
>


November 15, 2013
On Friday, 15 November 2013 at 08:50:14 UTC, Paulo Pinto wrote:
> It is an impossible task, because many of the D semantics cannot be expressed in JVM/Dalvik bytecode.

People are always targeting the impossible.
See http://nestedvm.ibex.org/ or http://da.vidr.cc/projects/lljvm/ as projects to express C in JVM bytecode.

Serious, the only problem is inline assembler. Everything else can be translated to JVM byte code.

Regards,
Kai
November 15, 2013
On Fri, 2013-11-15 at 09:44 +0200, Rory McGuire wrote: […]
> Nice one, I have to use Java at work, it would be awesome if I didn't have
> to.
> Would be cool if you make it so that the outputs to java are just trasforms
> of the AST that way people could write other types of output such as C.

Just use Scala, Ceylon, Kotlin or statically compiled Groovy instead of Java. Everyone I know who has ever tried it has never looked back.

Management can be handled easily since all the languages interwork well with Java, so change over to a new language is incremental, it does not require a revolution.

Java is dead, long live the JVM.

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

November 15, 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@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

« First   ‹ Prev
1 2 3 4