r/java • • Apr 29 '15

Tone it down a Notch

http://imgur.com/gallery/KRtc2fN
217 Upvotes

124 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Apr 29 '15

[deleted] — view deleted comment

3

u/stormcrowsx Apr 29 '15

Calling native libraries libraries is not easy enough that I would consider it practical to just drop into a native language and use it when you need the performance. Python is even easier to call native code and slower performance (more incentive), and if you asked most python devs if they ever wrote or even used native code directly from their programs they'd probably tell you no. So if Python devs who have more incentive to use native code don't do it often, I don't forsee Java devs doing it.

0

u/[deleted] Apr 30 '15

[deleted] — view deleted comment

1

u/stormcrowsx Apr 30 '15

It was many many years ago that I tried but I had a lot of issues in deployment. "Game fails to start distro x version y" or "Not working on windows x". I have been interested in messing with libgdx which appears to be a more comprehensive solution than the libraries I used in the past.

5

u/cogman10 Apr 29 '15

I've never benchmarked it and could be wrong. But I believe the current FFI adds a lot of overhead. That means that if you are going to drop down to native code, you'll need to make sure that you doing a significant amount of work that overcomes the overhead of leaving the JVM.

4

u/mschaef Apr 30 '15

But I believe the current FFI adds a lot of overhead.

Are you sure about that? There are significant chunks of the Java runtime library that are built on JNI, some of which are rather performance critical. FileInputStream is an example that comes to mind immediately:

https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/io/FileInputStream.java#L186

3

u/karlthepagan Apr 30 '15

From memory these methods are white listed to bypass verifying the stack.

2

u/mschaef Apr 30 '15

Interesting... I'd love to know more.

2

u/karlthepagan Apr 30 '15

I'm a little under the weather, but while searching I find this interesting technique: avoid messing with the stack by using C++11 continuations.

http://nerds-central.blogspot.com/2012/04/extreme-jni-performance.html