www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to interface with existing Java Code at the API level.

reply Matthew Ong <ongbp yahoo.com> writes:
Hi,

D has major potential to replace C/C++ at the system API level.
What I can see D is doing now is trying to glue to the existing C API
instead of replacing that OLD OLD language.

But it is too early to see if that is the case at the Business 
Application level to replace enterprise level resources(like JMS/MQ, .

Because of this, D could be a strong enhancement:
1) to allow other VM base language to interface with the native layer of 
the OS that they are sitting on.
2) hiding some implementation logic in pure machine binary.
3) speeding up some existing IO/Hardware interfacing that is not able
to be done by Java/C# directly.

I am not too sure how the D dll works completely, but I guess. The end 
results would be same as a C dll. but how to figure out the header file 
in the C compatible as that was written in D.

Then some example would needed to be provided

 From what I can see, as a starting show case project.

https://github.com/wmeissner/jffi



-- 
Matthew Ong
email: ongbp yahoo.com
May 21 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-05-21 01:04, Matthew Ong wrote:
 Hi,
 
 D has major potential to replace C/C++ at the system API level.
 What I can see D is doing now is trying to glue to the existing C API
 instead of replacing that OLD OLD language.
 
 But it is too early to see if that is the case at the Business
 Application level to replace enterprise level resources(like JMS/MQ, .
 
 Because of this, D could be a strong enhancement:
 1) to allow other VM base language to interface with the native layer of
 the OS that they are sitting on.
 2) hiding some implementation logic in pure machine binary.
 3) speeding up some existing IO/Hardware interfacing that is not able
 to be done by Java/C# directly.
 
 I am not too sure how the D dll works completely, but I guess. The end
 results would be same as a C dll. but how to figure out the header file
 in the C compatible as that was written in D.
 
 Then some example would needed to be provided
 
  From what I can see, as a starting show case project.
 
 https://github.com/wmeissner/jffi

The likely way to interface between D and Java would be to use a C (or maybe C++) interoperability layer in between them. I'm not sure that it can realistically be done any other way at this point. - Jonathan M Davis
May 21 2011
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 21/05/2011 09:58, Jonathan M Davis wrote:
 On 2011-05-21 01:04, Matthew Ong wrote:
 Hi,

 D has major potential to replace C/C++ at the system API level.
 What I can see D is doing now is trying to glue to the existing C API
 instead of replacing that OLD OLD language.

 But it is too early to see if that is the case at the Business
 Application level to replace enterprise level resources(like JMS/MQ, .

 Because of this, D could be a strong enhancement:
 1) to allow other VM base language to interface with the native layer of
 the OS that they are sitting on.
 2) hiding some implementation logic in pure machine binary.
 3) speeding up some existing IO/Hardware interfacing that is not able
 to be done by Java/C# directly.

 I am not too sure how the D dll works completely, but I guess. The end
 results would be same as a C dll. but how to figure out the header file
 in the C compatible as that was written in D.

 Then some example would needed to be provided

   From what I can see, as a starting show case project.

 https://github.com/wmeissner/jffi

The likely way to interface between D and Java would be to use a C (or maybe C++) interoperability layer in between them. I'm not sure that it can realistically be done any other way at this point. - Jonathan M Davis

As a side note, Bernard Helyer is working on import(Java) for his D compiler, and I believe Andrei is trying to persuade him to port it to work with dmd once he's done - https://github.com/bhelyer/SDC/commit/41d54a7a1fc57c3745493ee69b2be7bb59dc04c6 - I believe that allows for import(Java) my.java.class; -- Robert http://octarineparrot.com/
May 21 2011
parent Matthew Ong <ongbp yahoo.com> writes:
On 5/21/2011 11:27 PM, Robert Clipsham wrote:
 On 21/05/2011 09:58, Jonathan M Davis wrote:
 On 2011-05-21 01:04, Matthew Ong wrote:
 Hi,

 D has major potential to replace C/C++ at the system API level.
 What I can see D is doing now is trying to glue to the existing C API
 instead of replacing that OLD OLD language.

 But it is too early to see if that is the case at the Business
 Application level to replace enterprise level resources(like JMS/MQ, .

 Because of this, D could be a strong enhancement:
 1) to allow other VM base language to interface with the native layer of
 the OS that they are sitting on.
 2) hiding some implementation logic in pure machine binary.
 3) speeding up some existing IO/Hardware interfacing that is not able
 to be done by Java/C# directly.

 I am not too sure how the D dll works completely, but I guess. The end
 results would be same as a C dll. but how to figure out the header file
 in the C compatible as that was written in D.

 Then some example would needed to be provided

 From what I can see, as a starting show case project.

 https://github.com/wmeissner/jffi

The likely way to interface between D and Java would be to use a C (or maybe C++) interoperability layer in between them. I'm not sure that it can realistically be done any other way at this point. - Jonathan M Davis

As a side note, Bernard Helyer is working on import(Java) for his D compiler, and I believe Andrei is trying to persuade him to port it to work with dmd once he's done - https://github.com/bhelyer/SDC/commit/41d54a7a1fc57c3745493ee69b2be7bb59dc04c6 - I believe that allows for import(Java) my.java.class;

Cool!!! Ruby took off with JRuby because someone done such work for calling java api within ruby. According to JRuby people, JRuby now is faster than Ruby. That is from java into D and Not from D api into Java. Many cross platform GUI program with using some Java and linked into dll written by D. I can see that this is NOT the approach for that project. Will however take a look. -- Matthew Ong email: ongbp yahoo.com
May 23 2011