Thread overview
Translating Java into D
Nov 14, 2019
NonNull
Nov 15, 2019
Heromyth
Nov 15, 2019
Andre Pany
Nov 16, 2019
Heromyth
Nov 16, 2019
GreatSam4sure
Nov 16, 2019
Jacob Carlborg
Nov 16, 2019
Alexandru Ermicioi
Nov 16, 2019
DanielG
Nov 16, 2019
Jacob Carlborg
November 14, 2019
Greetings, Java seems to be almost a subset of D in various ways. Has there been any work done to automatically translate Java source into D?

November 15, 2019
On Thursday, 14 November 2019 at 19:50:22 UTC, NonNull wrote:
> Greetings, Java seems to be almost a subset of D in various ways.
No, it's not exactly right. Java is more powerful than D as for a language. Many things that Java can do can't be done by D. For example, reflection, full meta info for a type  in runtime, type deduction for a template, template member override.

See:
https://stackoverflow.com/questions/4829631/unusual-generic-syntax-arrays-stringaslist
https://www.baeldung.com/java-executor-service-tutorial

> Has there been any work done to automatically translate Java source into D?

We ported some projects in Java by hand.
November 15, 2019
On Friday, 15 November 2019 at 03:29:16 UTC, Heromyth wrote:
> On Thursday, 14 November 2019 at 19:50:22 UTC, NonNull wrote:
>> Greetings, Java seems to be almost a subset of D in various ways.
> No, it's not exactly right. Java is more powerful than D as for a language. Many things that Java can do can't be done by D. For example, reflection, full meta info for a type  in runtime, type deduction for a template, template member override.
>
> See:
> https://stackoverflow.com/questions/4829631/unusual-generic-syntax-arrays-stringaslist
> https://www.baeldung.com/java-executor-service-tutorial
>
>> Has there been any work done to automatically translate Java source into D?
>
> We ported some projects in Java by hand.

With the compile time reflection capabilities of D you can build a runtime reflection system. Therefore I would say D has reflection.

The other points I do not have enough knowledge what Java provides.

Kind regards
Andre
November 16, 2019
On Friday, 15 November 2019 at 13:15:29 UTC, Andre Pany wrote:
> On Friday, 15 November 2019 at 03:29:16 UTC, Heromyth wrote:
>> On Thursday, 14 November 2019 at 19:50:22 UTC, NonNull wrote:
>>> Greetings, Java seems to be almost a subset of D in various ways.
>> No, it's not exactly right. Java is more powerful than D as for a language. Many things that Java can do can't be done by D. For example, reflection, full meta info for a type  in runtime, type deduction for a template, template member override.
>>
>> See:
>> https://stackoverflow.com/questions/4829631/unusual-generic-syntax-arrays-stringaslist
>> https://www.baeldung.com/java-executor-service-tutorial
>>
>>> Has there been any work done to automatically translate Java source into D?
>>
>> We ported some projects in Java by hand.
>
> With the compile time reflection capabilities of D you can build a runtime reflection system. Therefore I would say D has reflection.
>
> The other points I do not have enough knowledge what Java provides.
>
> Kind regards
> Andre

Yes, you can do everything with D in theory. The fact is that there are many stuff waiting for you to implement them when you are porting a project from Java to D, like the different or missing APIs, language features etc.

See what we got from the portings:

Containers: https://github.com/huntlabs/hunt/tree/master/source/hunt/collection
Threading: https://github.com/huntlabs/hunt/tree/master/source/hunt/concurrency

November 16, 2019
Potentially relevant old thread:

https://forum.dlang.org/thread/ssdcoqhylmskfytfiian@forum.dlang.org

November 16, 2019
On Friday, 15 November 2019 at 03:29:16 UTC, Heromyth wrote:
> On Thursday, 14 November 2019 at 19:50:22 UTC, NonNull wrote:
>> Greetings, Java seems to be almost a subset of D in various ways.
> No, it's not exactly right. Java is more powerful than D as for a language. Many things that Java can do can't be done by D. For example, reflection, full meta info for a type  in runtime, type deduction for a template, template member override.
>
> See:
> https://stackoverflow.com/questions/4829631/unusual-generic-syntax-arrays-stringaslist
> https://www.baeldung.com/java-executor-service-tutorial
>
>> Has there been any work done to automatically translate Java source into D?
>
> We ported some projects in Java by hand.


?
I really sure of this? Can this be true
? Pls I need more clarity on this by professional in this group.


I am of the opinion that D is much more powerful than Java since I am familiar with the language to some extent. I am even to start a GUI app in java due to the fact I have no find a GUI toolkit in D that meet all my need.

I will appreciate detail analysis of this claim
November 16, 2019
On Friday, 15 November 2019 at 03:29:16 UTC, Heromyth wrote:
> On Thursday, 14 November 2019 at 19:50:22 UTC, NonNull wrote:
>> Greetings, Java seems to be almost a subset of D in various ways.
> No, it's not exactly right. Java is more powerful than D as for a language. Many things that Java can do can't be done by D. For example, reflection, full meta info for a type  in runtime, type deduction for a template, template member override.
>
> See:
> https://stackoverflow.com/questions/4829631/unusual-generic-syntax-arrays-stringaslist
> https://www.baeldung.com/java-executor-service-tutorial
>
>> Has there been any work done to automatically translate Java source into D?
>
> We ported some projects in Java by hand.

Regarding template member override. Generics in java are mainly compile time thing that boils down to auto generated casts when working with generic types (in bytecode), and therefore a templated method in java is actually a standard method that just works with Object class under the hood, hence it is possible to override in implementor of interface/class. It can be done in D too you'll just need to strip out generics part in method declaration and just use casts from root Object for worst case.

Also what do you mean by "type deduction for a template"?

Best regards,
Alexandru.
November 16, 2019
On 2019-11-14 20:50, NonNull wrote:
> Greetings, Java seems to be almost a subset of D in various ways. Has there been any work done to automatically translate Java source into D?

Yes, I'm working on a tool, JPort [1], for automatically translating Java to D. It's not done yet and there's been a couple of years now since I last worked on the project.

[1] https://github.com/d-widget-toolkit/jport/tree/dev

-- 
/Jacob Carlborg
November 16, 2019
On 2019-11-16 08:13, GreatSam4sure wrote:

> I am of the opinion that D is much more powerful than Java since I am familiar with the language to some extent. I am even to start a GUI app in java due to the fact I have no find a GUI toolkit in D that meet all my need.

There's DWT [1], which is a port of the Eclipse SWT Java library.

[1] https://github.com/d-widget-toolkit/dwt

-- 
/Jacob Carlborg