Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are programs written in Java for Android slower than equivalent written in C embedded into Objective-C for iOS?

In order to decide whether it is justified to start porting an existed iOS app (written in C) to Android, I have to estimate how fast will it be, if being implemented in Java. Some concern is the fact that Java code must be translated many times (to bytecode, then to a native one using JIT). It may affect a real time property (responsiveness) negatively , right?

What about the quality of generated code? Is it somehow comparable with gcc/llvm generated code? If yes, do you have a reference to the comparison results (paper)?

like image 496
psihodelia Avatar asked Nov 04 '11 14:11

psihodelia


2 Answers

Good question. Several years ago the performance of the Sun (now Oracle) JVM would pale in comparison to native code. But things have changed.

Firstly, the VM running Android isn't your standard JVM. Its a beefed up VM rewritten by Google specifically for mobile use, where UI performance is given priority.

Secondly, a lot has happened over the past decade... a quote from this relevant article puts it nicely: Fifteen years ago, all we thought that Java needed to rule the known universe was a faster VM. We now have a much faster VM.

Finally, there's been a lot written about comparisons between iOS and Android in terms of performance. Here's a fifth link just for kicks. There's plently more out there. It comes down to several factors - what type of code you need to run, what your performance expectations are, and how much you're willing to invest to squeeze out the most bang for your buck. And if you think Dalvik is your bottleneck, you're capable of writing native C/C++ and use JNI in Android.

like image 170
Pedantic Avatar answered Oct 09 '22 10:10

Pedantic


You can not compare the performance in this way. Your application will run on different pieces of hardware with different performance characteristics. The differences in performance between java/objective c is most probably negligible compared to the influence of the hardware. You should analyze the bottlenecks of your application and check if the targeted hardware can support it. If it's implemented in java does not matter that much.

like image 39
Arne Deutsch Avatar answered Oct 09 '22 11:10

Arne Deutsch