16 ms·
Python for Android
- dylangs1030 13y agoI don't use Android devices, so I wouldn't know, but is this the first instance of mobile Python on Android OS? Jailbroken iPhones have had this capability for years...not to say iOS is better, just that I'd expected this would happen...sooner? That said, the Python distro on iOS is only 2.6-ish, not even 2.7, and there's no 3.x release there. It's not very useful but I guess I did use it a lot for learning back then.
- MatthewPhillips 13y agoJython won't simply run on Davlik unmodified. Davlik is a brand new VM target for language designers, and Google hasn't put much effort into making it easy for other languages to run on it.
- gizmo686 13y agoIsn't there a tool that translates Java bytecode into Davlik byte-code (dx I think). Even if not, we have functioning decompilers to go from Java byte-code into Java source-code, and a well maintained toolchain to go from Java-source code to Dalvik byte-code. In fact, you don't even need a Java decompiler to do this. All you need is a backwords Java compiler. That is, one that treats bytecode as a source languages and compiles down to Java. This is a much easier process because (ignoring things like Enums) you don't need to try and figure out what the original code is, and instead can just do a naive decompile with optimization passes.
- yareally 13y agoThere's been some Jython ports to Android in the past, but all are abandoned as far as I know. There were some problems with performance as well and the dynamic nature of Python. I know there's a maintained JRuby project[1] for Android though. [1] http://ruboto.org/ http://ruboto.org/
- jnbiche 13y agoAnd there's also Myrah, a Ruby-like language that can produce Dalvik bytecode. I've been meaning to try it out for several years, it looks pretty promising. It's basically typed Ruby.
- yareally 13y agoHaven't heard of Mirah, but looks like it's still updated and maintained so that's a plus. http://www.mirah.org/ http://www.mirah.org/
- fabriceleal 13y ago> is this the first instance of mobile Python on Android OS? Honestly, I have no idea. But I'm aware that there are multiple efforts to bring "sane" languages (such as C#, by Xamarin) to Android, others than Java. > Jailbroken iPhones have had this capability for years I had no idea about this one, but I don't follow iOS development either. > I'd expected this would happen...sooner? I agree with you, but I believe this sort of thing should be backed by Apple (iOS) or Google (Android) themselves. [EDIT]: formatting
- dylangs1030 13y agoWell, I hope it's being done securely. I don't know much about the particulars of Android's iOS, but having a low-level language with access to the whole OS (which is what a real user would want for mobile programming, really) could be dangerous for native security. On the other hand, if Google or Apple backed a high-level scripting language like Python, that could also lead to security concerns, but I would feel safer with that than something like C on my mobile device.
- gizmo686 13y agoAndroid already has C. The only difference is that the public C API is relatively minimal, so to do anything useful you need to go through Java.
- jeffasinger 13y agoIn what scenario do you trust random C code more than random Python code? Unintentional security mistakes are much, much easier to make in C than most other languages. EDIT: Sorry if this came off as a little harsh, but I guess I'm curious as to what you think the security advantages of C over python are, when everything I've heard says the opposite.
- dylangs1030 13y agoReread my comment...I said I felt safer with Python over C. I'm well aware that, e.g. a buffer overflow is something you'd want to worry about in writing C code. I guess I worded my comment strangely? I said I would "rather have that" than C, to which I was referring to a high level language like Python.
- myko 13y agoPython has been on Android for a long time. The first instances I know of is SL4A: https://code.google.com/p/android-scripting/ https://code.google.com/p/android-scripting/ Kivy for Android has been around awhile as well.
- knappador 13y agoKivy developers are the primary movers behind Python for Android. Typically we are using Cython so that a great deal of the application is actually running in C without the Python runtime eating up overhead. This leaves a budget of about a million function calls per second, or roughly 10,000 per frame, as most of the overhead in the UI thread is eaten up in expensive function stack frame in the event system, passing around events that call callbacks that call callbacks that call callbacks... It remains to be seen if we can adopt a concurrent model for some aspects of the main application thread(s). Going concurrent almost surely means more Cython and more speed. I'm interested if anyone has any ideas about using CPython to reduce the cost of certain nearly-always-performed functions to grease the event system. Not that it's slow, but fast is always better =) http://kivy.org/#home http://kivy.org/#home
- dagw 13y agoNope, you've been able to run python scripts on your python phone for years. What this seems to do is make it easy to package together an app written in python into an independent package that you can install just like any other android app
- pudquick 13y ago> Jailbroken iPhones have had this capability for years As have non-jailbroken ones. I have Python for iOS and Pythonista (my preferred favorite) from the App Store. Python for iOS even comes in a 3.2 flavor.
- wyrag 13y agohttp://qpython.com/ http://qpython.com/ has been around for a while.
- limmeau 13y agoCompare this with the late PyS60, where you installed a little SIS on your phone, 2MB or so, and could then run simple Python scripts. Forwarding all incoming SMSs to another phone number was a six-liner or so. I've never used it to build big apps, only toyed around with examples, but then again, it wasn't made for the big applications, rather for small ad-hoc scripts. Kind of Eclipse plugins vs Emacs scripts.
- aswanson 13y agoA bigger question on my mind has been why would a shop as smart as Google not have started out with a sane language like python in the first place instead of foisting this java idiocy on another generation of devs.
- tvon 13y agoI think this decision was made by Android Inc. before Google purchased them.
- druiid 13y agoI've always wondered this as well. I mean, Google loves Python as evidenced by App Engine, how many of their internal/external tools use Python and other projects I'm forgetting. Basically I would have at least expected it as a built-in option to use (kind of like how Windows Phone 8 has a higher-level and lower-level way of accessing the phone).
- pekk 13y agoApp Engine has, if anything, better support for Java than Python.
- druiid 13y agoI might be remembering incorrectly, but wasn't the launch option for App Engine their home-grown version of web.py?
- bsimpson 13y agoThey started with Python and their own webapp framework; Java support came years later.
- jfoster 13y agoCan you give some examples of how that is the case? I don't know of any App Engine Services available on Java not available on Python (or vice-versa). They seem to be equally supported. It's Go & PHP that are in "Experimental" mode. (per https://developers.google.com/appengine/ https://developers.google.com/appengine/)
- daGrevis 13y agoThis is really cool! I'm interested in creating daemons that, for example, forwards SMSes to my email and records made voice calls. Is API good enough to do that?
- jnbiche 13y agoYes. Daemons are the one implementation where Python's longish start-up time on Android won't make any difference (we're talking a few seconds here, versus under a second for native Android apps, just to be clear). If anything you need is missing from the API, you can use Pyjynius to do easy Java interop. Another options for this kind of app is SL4A. They have a very complete Android API, but it's a bit harder to hack and not as well documented. If you want to package an APK, I think this project (Kivy's Python for Android) is probably a slightly better option. You can package APKs with SL4A, but it's a bit trickier. Python for Android even provides a virtual box image of Ubuntu (or Debian, I don't remember) for building APKs, with all the dependencies included, ready to go.
- daGrevis 13y agoSo I'm good to go. A pretty big challenge for me, but I will handle it at some weekend for sure! :)