I have been developing an image processing application in Java but I have been recently interested in VALA. The reason is because I believe I can increase the application performance (my concern is mainly in the interconnection with C/C++ libraries, as it seems <Example> that there is a performance punishment when using C/C++ bridges in Java).
Background (what I know):
There is something that is going around my head and I can't find the answer:
Any insight?
1. Can C/C++ consumable libraries be produced using an AOT compiler?
It should not be possible as we have no headers and it is not strictly a C class what the AOT compiler is creating but just machine code.
(Side note: Java classes can be called inside C/C++, but as AOT compilers produces a single binary file, I'm sure you can not access your Java classes from outside that file).
Answer: NO
2. Does the produced AOT binary, still has the bridge performance issue?
First, we need to know: if calling any C/C++ class from Java using a bridge (like JNI,javacpp,etc.) will always result in a performance loss?
According to "W_" from ##[email protected]:
it depends on how you're calling it (e.g. if arguments have to be converted and such). Just calling out to a library function without any arguments or return type conversion shouldn't take any different time than it does in any C app.
But as I'm using JavaCV as bridge for OpenCV library, it uses several type of objects which, if the above is true, it should affect the performance.
So, it may be logical that AOT compilation may speed-up a little bit the execution but still has to go through the bridge and do the type conversion.
Answer: YES (but may be slightly faster)
3. Calling C/C++ libraries in VALA has the same performance as calling them from C?
As it converts directly to C, I don't see a reason why not. This was supported by "nemequ" from #[email protected]:
pretty much, yes. vala has a habit of using temporary variables, but that's exactly the sort of thing most compilers can easily optimize away. if you're using gcc, pass -O2 and you should be good.
Answer: YES
Still I don't know why "someone" voted to close my question and he/she didn't even bothered to comment about it. I think these questions/answer are constructive enough (as pst commented) and they may be helpful for other people that are new to VALA or AOT compilers.
If my conclusions are not correct please correct me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With