Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could you use Apache Thrift instead of JNI?

I just came across Thrift and recently started playing with JNI.

From what I understand, Thrift provides you with the tools to define interfaces between different languages (correct me if I am wrong). JNI seems to do a similar job, in my experience, between Java and C++.

I was wondering if I could use Thrift to do the tasks I am currently doing in JNI. If yes, for what tasks should I use Thrift, and when should I use JNI?

Thanks!

like image 643
Karan Avatar asked Nov 19 '12 15:11

Karan


1 Answers

You should use thrift, or similar RPC library, when you are communicating between different processes. You can use JNI when passing method calls between Java and C in the same process. The cost of using thrift is approximately 10 - 100x higher than using JNI depending on what you doing which why you would only use it when you can't use JNI.

like image 133
Peter Lawrey Avatar answered Sep 28 '22 07:09

Peter Lawrey