Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it worth implementing C++ code through JNI in this application?

I'm developing a server application, and would like to harness the flexibility and (possible) speed increases C++ has to offer, by implementing the network code in C++. However, the base application has to be written in Java.

I'm aware of the possible reliability and debugging impact implementing JNI-code might have on the JVM. So I would like to know, would it be worth implementing such behavior in C++, or would the overhead caused simply not make it worth it?

Restriction: writing the application entirely in C++ is not an option.

Edit: I am a skilled (not very, but I can solve most tasks) C++ programmer, and I plan to use a library, do you have any suggestions?

Main criteria:

  1. Speed
  2. Raises the abstraction level
  3. Event dispatched
  4. Asynchronous (I will synchronize the code in Java before calling the C++ functions)
  5. Has support for/is multithreaded)
like image 204
Benjamin Avatar asked Dec 08 '25 03:12

Benjamin


1 Answers

No, it will not be worth it for the reasons you mentioned (related to overhead) and without getting into any c++/java wars about performance, there wouldn't be enough of it (performance) to impact the throughput of client/server type of calls.

In most client/server type of applications, the movement of data across the network itself and the application level processing will constitute the vast majority of your time. Basically the amount of time spent in the servers network layer will be such a small percentage of the total time that performance benefits won't make enough of a difference.

Whether this balance holds true in your particular case, I cannot say since I don't know the nature of your application, but I would say it is the typical case.

like image 68
Robin Avatar answered Dec 10 '25 17:12

Robin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!