target both android and iphone with Python [duplicate]
I want to开发者_运维技巧 develop an application targeting both android and iphone. I guess they use Java and Objective-C. Can I use single language like Python? Is it the best route? Will I lose performance, features, etc. by using Python. Are there any limitations that I will run into?
You cannot use Python on either of Android or iPhone platforms. This is clearly outruled by Apple SDK license, while with Android there actually is an Android scripting environment, but you will quickly realize that is not meant for the final user. In any case, the fact that Python is not supported on iPhone rules this out as a cross-platform option.
I think that the only way to build a truly cross-platform app supporting Android and iPhone is by means of HTML5. Of course, HTML5 apps are not fully native, but you might come-up with a mixed design where you use HTML5 content hosted locally on the device or on your site and display it in a native veb view.
Pure HTML5 apps are not fully native in that they are HTML5 and not CocoaTouch (Android) apps. They only can do what HTML5 allows and with an HTML5 look-and-feel. One major limitation is the unavailability of special hardware available on the device, like the accelerometer, the gyro, whatever. They offer, anyway, much flexibility and the maximum of cross-platform compatibility.
This is an extreme. The other extreme is "fully native apps", i.e. apps developed in Objective C/Cocoa Touch or Java/Android. Full access to the SDK, to special hardware, native look and feel, no compatibility across platforms.
There is a third possibility, which is a mixed app. You can define a native skeleton UI (say, on iPhone, a navigation based app) and provide the content of your view and the detailed interface through HTML5. The skeleton UI will not be portable, but it will allow you to do much more that what you could on a pure HTML5 app. This approach usually requires the use of an HTML viewer class in your app, so that you have: skeleton UI + native web viewer + HTML5 content.
About "HTML5 content hosted locally on the device": you can either host your HTML5 app on a web server, or locally to the device and load it from there (no web access).
phonegap is one of the way that you can use to target the iphone & android.through the javascript,html.
The closest thing I know of are the MonoTouch and MonoDroid projects. They allow you to write C# code rather than Objective-C (for iPhone) and Java (for Android). The issue comes in the UI, since there is no generalized abstraction for the different UI models. Ideally you could write your core business/domain/whatever code in such a way that it is not tied to the UI and then get some reuse that way.
I've not seen Appcelerator, which @Snicolas mentioned, but it may do a better job at providing the total abstraction across both platforms.
I would consider just biting the bullet and aiming for the ultimate goal of eventually learning both Java and C/Objective-C. I have some comparisons here. So perhaps write a simple app in Java/Android and then try to replicate it in iOS/C/Objective C. If you take this aim for the stars to land on the moon approach, you will forget how many languages you have learned over your life time.
精彩评论