My Android project nearing beta

Adam D. Ruppe destructionator at gmail.com
Wed Jan 8 14:13:58 UTC 2020


On Wednesday, 8 January 2020 at 12:10:15 UTC, Chris wrote:
> 1. How does it fare performance wise with JNI? In the Android 
> docs they advise you not to use the JNI bridge very often as it 
> very costly.

I don't know. I don't even have a plan to actually test it at 
this point.

Worth remembering that I'm talking a lot about the jni thing 
because it is new, but I suspect the majority of use wouldn't hit 
it often, and possibly not at all. Just the extern(C) NDK and 
OpenGL functions are already a solved problem so much as much to 
say there in terms of new developments.

But I do use various techniques internally to minimize the calls: 
it slices strings rather than copying them (where possible), 
caches lookup results for classes and methods, avoids pinning 
references where possible (though this will have to partially 
change with the implementation expanding too!) and will do lazy 
loading of object arrays (right now it is simply not implemented).

Just there is indeed some cost on the jvm side we can't avoid. 
But using D code and the C functions for the majority should 
minimize the impact too; the jni might be limited to setup and 
some user interaction callback stuff where speed is adequate even 
if not great.

> 2. The new JVM default language for Android is Kotlin. How will 
> you handle that?

Doesn't affect anything as far as I can tell, except possibly 
slightly awkward syntax when compared side by side with stuff 
like kotlin extension methods - even my bindings generator (which 
you don't have to use btw) doesn't look at the source, instead 
pulling the data right out of the compiled class files. Since 
kotlin compiles to the same thing as java, it should work the 
same way.

(the biggest problem I've had with the jni thing btw: default 
implementations in interfaces. yikes. but i think i have a plan. 
otherwise the other pains are just me trying to keep compile time 
and memory usage down, so some hacks to do that while still 
keeping all of java available on demand. But that isn't used in 
anything Android I've found so far.)

We should probably test it more to be sure though.


More information about the Digitalmars-d-announce mailing list