1

I have seen many libraries provide high level API in the language like python or lua. For example:

  1. The linear algebra library "Trilinos" provides a python API.
  2. The deep learning framework "torch" provides a lua API.

However, I can hardly find C/C++/CUDA libraries which provide APIs for Java/Jython/Scala or any other JVM languages. Of course there are exceptions, e.g. OpenCV provides API both for python and java.

I want to know except for the language(for example python is good for analyzing or a small script), is there any other reasons stop C libraries provides API for JVM language?

Personally I think using scala for scripting is as convenient as python. But not so many C libs support scala. Maybe it is not popular enough.

Does the design of the JVM make it difficult of doing that?

  • 1
    I suspect it has more to do with target audience than anything else. Porting the entire API to another language, even if easy to do, probably isn't worth officially supporting long-term unless you know there are people working in that language who have no "native equivalent" of your library but need its functionality. Java has far more stuff in its own standard library than Lua does, so it seems reasonable that this happens much more often for Lua than Java. – Ixrec Mar 3 '16 at 1:15
  • @lxrec What you have said quite makes sense. However since the C libs provides python APIs, the author must want to make the lib easy to use, not only to attract python programmers. We have to admit writing code in python is much easier in C. Since the author choose python instead of Java, there must be some reasons. – worldterminator Mar 3 '16 at 1:22
  • 1
    Python and LUA are specifically designed to make scripting easy. – Robert Harvey Mar 3 '16 at 1:30
  • @RobertHarvey Yes, I agree. But I am asking other reasons than language(e.g. grammar). – worldterminator Mar 3 '16 at 1:51
  • Not that I know of. You don't think the scripting aspect is sufficient motivation? – Robert Harvey Mar 3 '16 at 1:57
2

One chooses to integrate whatever language one chooses. That's really as far as one can go with that line of reasoning.

Python is incredibly popular right now. Python integration is the kind of feature which can sell your product. Accordingly, there is a great deal of interest in Python integration, and unsurprisingly we see a large number of libraries that provide Python integration. It's very much a snake eating its own tail.

Lua is unique because it is actually extraordinarily easy to integrate. It is a language that was designed, from day one, to be easy to integrate into a C or C++ application. So in this case, yes, Lua is chosen because JNI is much harder than Lua integration, but that's less of a statement about JNI and more of a statement about how well Lua developers did their job.

Personally, I find JNI's memory model difficulty on par with managing Python objects. But if I expose my software to Python, lots of people are very very happy. If I expose it with JNI, fewer people rejoice.

Not the answer you're looking for? Browse other questions tagged or ask your own question.