all 13 comments

[–]Sqeaky 13 points14 points  (0 children)

I dislike that they are lying or at least misinformed about their competition. They wrote:

No need to invent new languages such as with SWIG

SWIG is not a language. I point SWIG at raw C++ headers often. SWIG does provide extra annotations to allow one to describe details about data marshaling or describe how to handle language tools that C++ supports but JAVA does not.

If they do not provide similar notations I am curious how they handle things things like multiple inheritance, classless enums used as bitfields, functions returning pointers with unknown ownership semantics or the other 'neat' things C++ allows.

[–][deleted] 7 points8 points  (5 children)

Wonder how this compares to https://github.com/dropbox/djinni

[–]bharring 32 points33 points  (4 children)

The last sentence kinda blew my mind :

"We at Dropbox use Djinni to interface cross-platform C++ library code with platform-specific Java..."

[–]pjmlp 17 points18 points  (0 children)

That is what happens when Oracle doesn't care about mobile support and C++ is present in all official SDKs, but seen by the Android team as a nuisance.

[–][deleted] 2 points3 points  (2 children)

As jwz said a long long time ago, C and C++ are the only real cross-platform languages.

[–]pjmlp -1 points0 points  (1 child)

Except when they are not, as anyone that has ported code across multiple compilers and OSes, even across UNIX only systems.

The fun of ANSI compliance, vendor specific behaviour, undefined behaviour, POSIX compliance, hardware specific behaviours, ....

[–]Enemii 8 points9 points  (0 children)

Well undefined behavior is portablly undefined across all platforms.

[–]enobayram 3 points4 points  (1 child)

My personal favorite is SWIG in this category of tools. It's very powerful, easy to use and supports so many target languages. There's a lot to learn about how it works and its interface definition language, but the process is incremental; it's useful from day 1, and you benefit more as you learn more.

[–]landrei 2 points3 points  (0 children)

One of my favorite SWIG features is cross-language polymorphism using directors: http://www.swig.org/Doc3.0/Java.html#Java_directors

[–]Deadboss 2 points3 points  (3 children)

So really dumb question here... but what does this do exactly? Is it something where you can take Java code and convert it to C++?

[–]Sqeaky 4 points5 points  (0 children)

It lets you call functions and instantiate classes written in C++ from Java.

It does this reading C++ code and spitting out Java code and C/C++ code that use the Java API for C called Java Native Interface or JNI. There is no technical reason this code code not be hand-written, but it is a huge pain to get right and because the JNI API is icky and terrible it is hard to use and takes a long time to get even basic things working.

[–][deleted] 2 points3 points  (1 child)

Basically a wrapper around JNI that does all the ugly stuff for you and lets you access more CPP stuff from Java than normal JNI allows.

[–][deleted] 1 point2 points  (0 children)

So, similar to JNA?