Python or Java? Whats better for mobile development, and GUI applications
I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and GUI development.
Are there开发者_开发百科 any mobile platforms that run Python, or should I go the Java route?
Java is certainly available on more platforms. I would pick a target platform (or set of targets) and see what language(s) would require the least number of redundant implementations.
Also, when you get to a certain level of complexity, the language often doesn't factor into speed. For initial prototypes, sure some languages are lightning fast to develop in, but by the time you've taken care of all the exception cases and tripled the entire schedule due to QA, you'll find that the prototype development speed wasn't all that big a deal.
Of course, depending on the complexity of your app, this may prove to be untrue--a small simple app can be delivered in near "prototype time".
Google have released the Android Scripting Environment (ASE) which lets you write programs for Android in a variety of scripting languages including Python and Ruby. However currently there is no way to release an app written in these languages, although Google are rumoured to be working on it.
More generally the biggest resource constraint on mobile devices is battery power. Since dynamic interpreted languages generally have a higher CPU overhead than a statically typed language a Python program will be a bigger battery drain than the Java equivalent.
On top of this you will need to ship the entire Python runtime with the program, while the Java runtime will already be included on the device. This means more memory overhead - another scarce resource on a mobile.
For the moment at least I would not use Python or similar scripting language for serious Android development - it can be useful for rapid prototyping but not for production quality apps. I say this with a heavy heart, since I love Python and strongly dislike Java. A possible compromise is Scala - it is statically typed but uses type inference to remove a lot of the overhead of Java, and feels more like Python to develop in. Also like Python it is a mixed Object Oriented and functional language (unlike Java, which is Object Disoriented and disfunctional). There are a lot of people experimenting with using Scala for Android development, since it compiles down to Java class files that are as efficient as the equivalent Java code.
I don't know what the situation is on the iPhone - given Apple's prohibition on the iStore carrying apps written any anything other that the officially sanctioned languages I think it is an unlikely fit.
I know there is a version of Python for Window Mobile, but again AFAIK there is no way to package a python program up into a releasable app.
The first question is whether you really need to develop an app, which requires per-platform work, vs a webapp.
If you really need an app, then you might likely need a separate language for each platform! For Android you'd want to use Java, and for iPhone/iPad you'd want to use Objective-C. A good argument for really trying to go the webapp route.
精彩评论