<<< WARNING >>>
This post is extremely computer nerdy.
Viewer discretion is advised.
As you all know, thanks to B4A's external library support, we've been able to write our own Java libraries for a while now. This is such an incredible feature, but since I was never familiar with Java, whenever I needed something really specific, I was always dependent on someone else's good will to write some code for me.
I was, however, familiar with the C language, so last summer I decided to give JNI a try. After some (many) NDK/JNI tutorials, I was finally able to take my first steps on creating native-based B4A libraries.
Happy with the result, but unhappy with the JNI syntax (which is horrible, btw), I created a
helper tool which allowed me to write regular C/C++ code and have a B4A library generated in seconds.
Unchained from having to carefully craft JNI functions by hand, my productivity was immensely increased.
Soon I realized, from a game designer perspective,
B4A and C++ is a match made in heaven! The possibilities are endless. The friendliness of Erel's IDE and B4x syntex, powered by natively written functions.
Just when I thought things couldn't get any faster, I discovered that C/C++ has inline support for assembly commands. Of course, one has to be very careful because when using those, since they're quite hardware specific.
At this point it really feels like I've reached the core. I'm as close to the hardware as humanly possible.
I started to measure my cycles and loops in nanoseconds. Suddenly now, a millisecond seems like an eternity.
So there you have it, if you have a mad scientist spirit like me, I'm here to let you know that, you can write
Assembly code, using
C/C++ inline functions, compile it into an .so library to be used by a
Java library which can be wrapped into a
B4A library.
tl;dr:
B4A --> Java --> C/C++ --> Assembly
B4A <-- Java <-- C/C++ <-- Assembly
Yes, we can.
...and that's how we can go deeper, harder and faster, at least in terms of coding.