Starting with Android: Java or Python (SL4A)
Asked Answered
S

5

12

I just ordered an Android smartphone and want to start playing around with creating my own applications. Now the question is which language to use, the native Java or Python using SL4A (former ASE).

I tend to Python, as I know it much better than Java, but I'm wondering what I would be missing using a "second class" language on Android. On the SL4A website it is also stated to be alpha quality software, which is not exactly encouraging.

I'm also not quite sure what the limitations of the scripting environment are and if they would be problematic.

Sync answered 27/7, 2010 at 19:4 Comment(0)
N
16

At the moment you cannot create a releasable program with Python (or any other scripting language) using SL4A. I have heard rumours that this is something Google is working on, but even if they do enable it Python apps are likely to be slow and power-hungry compared to Java. Also the scripting API only gives you access to a limited subset of the native Java API. I would not consider using SL4A for serious development work at the moment, only for one-off scripts and prototyping.

Take a look at Scala. It is a statically typed language on the JVM, but uses type inference to remove most of the noise that you get in Java. It also fully supports functional programming, and has a lot of pythonish features. Because it is statically typed it is as efficient as straight Java with none of the disadvantages. IMHO it is the language that Java should have been in the first place.

A lot of people are blogging about using Scala on Android, so Google around for more information.

Nappe answered 27/7, 2010 at 20:19 Comment(5)
I'll definitely take a look at Scala, should be interesting.Sync
Depends on how you code your program. If you are an experienced Python programmer, go for it, as it is sufficiently fast for most (or almost all) purposes. Just avoid Java whenever you can.Overhappy
@otz: for regular desktop programs I would agree with you, but as I said in my post (1) there is currently no way to turn a python script into a releasable Android app, (2) the SL4A Python implementation does not give access to the full Android API and (3) on a mobile phone battery usage is paramount. A dynamic language like python is going to use more juice than the Java or Scala equivalent.Nappe
@dave Kirby, you CAN package your scripts into an .apk and distribute. check out code.google.com/p/android-scripting/wiki/SharingScripts Its really easy and quite honestly I haven't noticed a 'slow-down' for anything I've developed. Python is great because I already have SO many running programs (urllib POST apps) that I can quite literally just port to android very easily. Combine this with sl4a's webview intergration and you have a GREAT tool to do what you want very rapidly!Monica
@Dave Kirby ~ g19 is correct; you've been able to package and distribute Python Android apps for ages. There may be technical reasons to use Java, but your answer is way off the facts. The 'subset' of the Android API is not especially 'limited', and is fine for many applications. The question specifically mentions wanting "to start playing around with creating my own applications" which SL4A is much better suited to than Java, at least for someone who leans towards "Python, as I know it much better than Java".Cumulostratus
C
2

More likely will depend what type of applications you will develop.

I would start with Java to become familiar with Android SDK. Anyway first you need to look into some examples, tutorials. Most of them are done in Java, and only a few, probably on the dev site of SL4A for that.

Also there is native development Android NDK, that can be programmed with C++.

But anyway Java rules for general applications.

Conspiracy answered 27/7, 2010 at 19:12 Comment(1)
I didn't think about tutorials/documentation, that's a good point. So I probably should start in Java anyways, regardless which language I use in the end.Sync
D
2

Adding an update to Dave Kirby's answer:

Issue 55, Distribute scripts as APKs, in the issue tracker at SL4A deals specifically with that.

There is a solution being worked out (may be complete by now) described at SharingScripts. The only issue seems to be that you need to have a interpreter APK already installed.

Dipsomaniac answered 28/8, 2010 at 9:0 Comment(0)
F
1

you may want to check out Ruboto it is a framework for developing Android apps based on JRuby which means your JRuby code can call Android APIs and can also be called back from the Android Java side. Here is an introduction article .

Fitzpatrick answered 11/1, 2012 at 7:53 Comment(0)
L
1

Consider ising Kivy, if you want to write Android apps with Python. The process of packing script to .apk file is described here.

The problem is, resulting .apk will be big (~7Mb for 300Kb data). It is obvious, because you need to pack there Python runtime and all libraries.

Another solution I have heard of, is Pygame for Android, but it works on lower lewel, so you need to draw graphics manually.

Unfortunately, I have not tried any of this ways yet, but it looks, that I'm going to start using kivy soon.

Lilithe answered 21/9, 2013 at 8:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.