Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know that an app developed with PhoneGap is slower than a native one because at PhoneGap the whole code must be interpreted at runtime into a native one.

But could someone explain or has a good in-depth website which explains why a native app retrieves data (a picture or text) from a web ressource faster than an app with PhoneGap? Do both apps handle internet connections in another way, or is there more data retrieved by an PhoneGap app?

share|improve this question
4  
Are you sure that it is the time it takes to retrieve data across the network is different? or is it the using the data once it has been retrieved is different? –  MichaelT May 14 '13 at 20:04
2  
First, how have you benchmarked the relative speeds by which native apps and Phonegap apps fetch resources? –  user16764 May 14 '13 at 20:15
1  
benchmarked it with "boomerang" from yahoo and coded the same app native (xcode, iphone) and with phonegap. –  John Brunner May 14 '13 at 20:36
add comment

1 Answer

up vote 4 down vote accepted

It's a totally different application event process.

PhoneGap uses JavaScript event callbacks that are designed to be generic across multiple devices, whereas Android is activity based which is native to the OS. iOS has something simular but I can't comment on that.

Android knows which activity to start when the application is loaded, and execution of that activity happens relatively quickly even for large applications. Whereas, PhoneGap requires a HTML5 browser to finish loading, then all the HTML5 JavaScript files have to load from the device and the JavaScript has to be executed at least once to initialize all the code. As a result there is a visible delay in starting PhoneGap applications. That's why PhoneGap includes a splash screen feature while the app loads.

After a PhoneGap application has started the entire user interface is a rendered HTML page, which is subject to performance issues relative to the device it's on. Whereas, native Android applications often use the OS to render their activity view. So improvements in the speed of the OS translate to faster apps. HTML rendered by a browser is limited to the speed of the processor and GPU.

Performance Should Be The Same When

  • Applications can take advantage of local storage, caching and SQL.
  • Communication with the web server is done via AJAX (JSON, XML or HTML).

Performance Should Be Different

  • Javascript is used to perform large calculations.
  • The user interface displays data from a large data source.
  • Read/Write operations to local storage are in large amounts (i.e. camera images)
  • All visual elements that involve animation or large graphics would be faster done natively.

Hybrid PhoneGab

There is no good reason for a PhoneGap developer to complain about performance. PhoneGap allows you to develop code for each device that runs natively, and can be executed via a plugin to PhoneGap. The native plugin is exposed to the PhoneGap app as a Javascript extension. Any time performance is an issue the developer has the option to move that code to a native plugin.

While JavaScript is slower than native code. What is it the code is doing that makes it so slow? Most likely it's bad Javascript then a fault in the design of PhoneGap.

Why PhoneGab?

PhoneGab is not Android development. It's HTML5 and personally the Android SDK can allow you to achieve results often faster than implementing the same thing in HTML. I think people who have strong skills in HTML/Javascript have very specific user interface expectations, and recoil at the idea of the OS imposing standards.

share|improve this answer
    
thanks for the answer! –  John Brunner May 14 '13 at 20:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.