• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java JNI Target Languages Other than C / C++  RSS feed

 
Alvin Parker
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My motivation for this question is that I have to support a client with a large Java / ActionScript implementation (solution runs on win and mac). To solve part of a problem they had, I needed to introduce some native software. I found a C++ package that had a JNI wrapper around it and used that. But, it's out of date, there's no support for it and I don't know C++ beyond a rudimentary level. I am considering learning another uninterpreted language and re-writing the native source in that due to the fact that I think it would be far slower to become proficient in C++ than other languages that may exist and given the dwindling C++ resources (even with C++11), I think I would be better off learning something growing rather than declining.

I have heard of Haskell and understand that's a natural language to learn. It also appears that there is some support for doing JNI type things with it. Has anyone faced this issue in the past? What languages have you found to be able to produce an artifact that Java can then call? I'm looking for suggestions on languages that I could learn that would be comfortable (and relatively fast) to learn and that will produce .dll or .dylib (or any other native artifact) that can be accessed within Java.

Thanks for the input.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about how to interface Java with Haskell, but be aware that Haskell is a very different kind of language than Java or C++.

It's a functional programming language, not an object oriented programming language. If you've never done functional programming, then you're going to have a steep learning curve; functional programming is a completely different way of programming than object oriented or procedural programming. It will be at least as hard as learning some rudimentary C++. If this is for a commercial client, you should consult with them, because someone will have to maintain the software in the future and Haskell is very much a niche language, they will have a hard time finding someone who understands it and who can maintain the code. (Ofcourse it's cool and interesting to learn a new language, and I've looked into Haskell myself, but I'd not use it for any commercial job unless there's a very good reason for it).

Why don't you rewrite the native part in Java, or is that not possible for some reason?
 
Alvin Parker
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper for the honest feedback and warning.

It is a commercial client. And, I do want to make sure that what I leave them with does not make future developers want to shoot me. I am also interested in saving myself time and see no reason to learn something that does not rapidly add to my ability to achieve results for myself and clients. From continued research on this, it appears that there are extensive solutions for Java to communicate with native libraries, beyond JNI and there may be several languages that can help me accomplish goals. So my question remains... Knowing that I'm an entrenched Java programmer, what would be a good language to learn for those times when I need to do something natively that Java just can't do - and by native, I mean specifically desktop development? I know this is a subjective question. I am interested in others subjective responses. I don't care if I have to connect with JNI, RPC or JNA, I just want a language that is friendly to a Java programmer and has some way to accomplish direct Java instantiation and consumption.

EDIT:
The native part used to be in Java. It's based on the javax.sound packages. The program processes MIDI data. The problem we found is that on many systems the MIDI cable is not found or suddenly gets lost. Changing to a native solution fixed the problem. There were also sound drops during accompaniment - sound would play for some period of time, drop out and then pick back up in the middle of the accompaniment. I fixed that as well by sending MIDI signals myself and skipping javax.sound. But all of this requires native work and I don't like having solutions in place I don't understand / have a hard time supporting. There are other reasons I need to do native programming from time to time and I'd like to have a language I know fits the bill when it is needed.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can find no on-line review of computer language usage that puts Haskell in the top 10 languages but to balance that I can find no on-line review of computer language usage that can be considered as authoritative. What I can say from experience is that you can't go far wrong with 'C' and 'C++'. All the on-line (non authoritative) reviews of computer languages that I find put Java, 'C' and 'C++' very near the top if not at the top. Outside of Java my preference is for C++ but that is because I spent many years earning a living from 'C' and 'C++' before moving on to Java. In some ways I still consider 'C++' superior to Java but for most desktop applications I find using Java allows me to more quickly create applications portable across platforms.

If you are writing code for a client then I would ask him what his language preference is. I'm betting it would be either 'C' or 'C++' because when you have moved on he will be able to get programmers to support the code much more easily than if the code is written in Haskell .

You say you are currently using "C++ package that had a JNI wrapper around it and used that. But, it's out of date, there's no support for it" . Do you really want to re-code the 'C++' in Haskell ? If you did you would have Haskell code without support written by somebody new to Haskell ! It would seem much more logical to me obtain the source code for the existing 'C++' and use that.



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!