From david at boddie.org.uk Tue May 17 12:05:51 2016 From: david at boddie.org.uk (David Boddie) Date: Tue, 17 May 2016 18:05:51 +0200 Subject: [Mobile-sig] Experiments with Dalvik Message-ID: <201605171805.51312.david@boddie.org.uk> In a belated attempt to jump on the Android bandwagon I started to look into learning Java and the Android APIs. I realised very quickly that I couldn't face writing a lot of code in that language. Looking around for other languages running on the Dalvik VM, I found a few that might be nicer than Java, but I wasn't so sure that I wanted to write in any of those, either. In the end, I decided to try an experiment to see how much I could learn about Dalvik and Java by creating tools to handle some of the file formats used in Android packaging, and by trying to implement a compiler for a subset of Python. The result can be found in this repository: https://bitbucket.org/dboddie/duck It should be noted that the source language isn't really Python. The parser from the standard library is used to parse it, but the semantics of the generated code are different to those of Python. That's why I gave the language a different name. How is this relevant to a mailing list about Python on mobile platforms? Firstly, the language may be close enough to Python for people to find it more familiar than Java, even if there are places where the differences may trip them up. Writing code to fit into a framework designed for a statically typed language requires a slightly different mindset to the one you might have when writing regular Python code, so it may not seem so strange to developers once they've accepted that. Secondly, it makes it possible to write a more faithful implementation of Python using code that looks a lot like Python, instead of Java. You could use it to write support code for a compiler, or perhaps write an interpreter in it. It's all very experimental at the moment. I've been uncomfortable about publishing it before now because I keep finding things I've overlooked, though it's been a good learning experience. Maybe there will be things in there that people find useful. David From gwidion at gmail.com Tue May 17 13:16:08 2016 From: gwidion at gmail.com (Joao S. O. Bueno) Date: Tue, 17 May 2016 14:16:08 -0300 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: <201605171805.51312.david@boddie.org.uk> References: <201605171805.51312.david@boddie.org.uk> Message-ID: Thanks for sharing that. On 17 May 2016 at 13:05, David Boddie wrote: > In a belated attempt to jump on the Android bandwagon I started to look > into learning Java and the Android APIs. I realised very quickly that I > couldn't face writing a lot of code in that language. Looking around for > other languages running on the Dalvik VM, I found a few that might be nicer > than Java, but I wasn't so sure that I wanted to write in any of those, > either. ... From dimaqq at gmail.com Tue May 17 13:18:01 2016 From: dimaqq at gmail.com (Dima Tisnek) Date: Tue, 17 May 2016 19:18:01 +0200 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: References: <201605171805.51312.david@boddie.org.uk> Message-ID: How about python-java bridge, like Rubicon or pyjnius? You get best of both worlds -- a good language and a mature runtime. On 17 May 2016 18:05, "David Boddie" wrote: In a belated attempt to jump on the Android bandwagon I started to look into learning Java and the Android APIs. I realised very quickly that I couldn't face writing a lot of code in that language. Looking around for other languages running on the Dalvik VM, I found a few that might be nicer than Java, but I wasn't so sure that I wanted to write in any of those, either. In the end, I decided to try an experiment to see how much I could learn about Dalvik and Java by creating tools to handle some of the file formats used in Android packaging, and by trying to implement a compiler for a subset of Python. The result can be found in this repository: https://bitbucket.org/dboddie/duck It should be noted that the source language isn't really Python. The parser from the standard library is used to parse it, but the semantics of the generated code are different to those of Python. That's why I gave the language a different name. How is this relevant to a mailing list about Python on mobile platforms? Firstly, the language may be close enough to Python for people to find it more familiar than Java, even if there are places where the differences may trip them up. Writing code to fit into a framework designed for a statically typed language requires a slightly different mindset to the one you might have when writing regular Python code, so it may not seem so strange to developers once they've accepted that. Secondly, it makes it possible to write a more faithful implementation of Python using code that looks a lot like Python, instead of Java. You could use it to write support code for a compiler, or perhaps write an interpreter in it. It's all very experimental at the moment. I've been uncomfortable about publishing it before now because I keep finding things I've overlooked, though it's been a good learning experience. Maybe there will be things in there that people find useful. David _______________________________________________ Mobile-sig mailing list Mobile-sig at python.org https://mail.python.org/mailman/listinfo/mobile-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Tue May 17 14:36:31 2016 From: janssen at parc.com (Bill Janssen) Date: Tue, 17 May 2016 11:36:31 -0700 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: References: <201605171805.51312.david@boddie.org.uk> Message-ID: <7809.1463510191@parc.com> In case you weren't aware, you can just write Android apps and services in Python, using Kivy. No need to invent another language. Bill Joao S. O. Bueno wrote: > Thanks for sharing that. > > On 17 May 2016 at 13:05, David Boddie wrote: > > In a belated attempt to jump on the Android bandwagon I started to look > > into learning Java and the Android APIs. I realised very quickly that I > > couldn't face writing a lot of code in that language. Looking around for > > other languages running on the Dalvik VM, I found a few that might be nicer > > than Java, but I wasn't so sure that I wanted to write in any of those, > > either. > ... > _______________________________________________ > Mobile-sig mailing list > Mobile-sig at python.org > https://mail.python.org/mailman/listinfo/mobile-sig From gwidion at gmail.com Tue May 17 15:15:04 2016 From: gwidion at gmail.com (Joao S. O. Bueno) Date: Tue, 17 May 2016 16:15:04 -0300 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: <7809.1463510191@parc.com> References: <201605171805.51312.david@boddie.org.uk> <7809.1463510191@parc.com> Message-ID: The point of the toolset David just borught up is not just about 'an entire oher language' - it is a toolset for being able to manipulate android assets, and that is in Python. And the new language, that comes up for free, is different from Kivy and other approaches, in the sense it compiles python-like source ode directly to Dalvik bytecode - it is not the same as(1) building Python natively on Android, and not the same as emulating Python over Java. I don't think replying to someone who is bringing a totally cool, months long project, with lots of tools, innovations and possibilities with "you could have used X" is anything constructive - at least not if one does not at least take a look on what is being presented. I don't think Kivy is good for getting performatic, or native-looking apps, when talking about Python, for example. And also, the tools to handle android assets in this repo could even be used to replace the need for Android SDK when building Kivy based apps. js -><- On 17 May 2016 at 15:36, Bill Janssen wrote: > In case you weren't aware, you can just write Android apps and services > in Python, using Kivy. No need to invent another language. > > Bill > > Joao S. O. Bueno wrote: > >> Thanks for sharing that. >> >> On 17 May 2016 at 13:05, David Boddie wrote: >> > In a belated attempt to jump on the Android bandwagon I started to look >> > into learning Java and the Android APIs. I realised very quickly that I >> > couldn't face writing a lot of code in that language. Looking around for >> > other languages running on the Dalvik VM, I found a few that might be nicer >> > than Java, but I wasn't so sure that I wanted to write in any of those, >> > either. >> ... >> _______________________________________________ >> Mobile-sig mailing list >> Mobile-sig at python.org >> https://mail.python.org/mailman/listinfo/mobile-sig From david at boddie.org.uk Tue May 17 15:26:17 2016 From: david at boddie.org.uk (David Boddie) Date: Tue, 17 May 2016 21:26:17 +0200 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: <7809.1463510191@parc.com> Message-ID: <201605172126.17409.david@boddie.org.uk> On Tue May 17 14:36:31 EDT 2016, Bill Janssen wrote: > In case you weren't aware, you can just write Android apps and services > in Python, using Kivy. No need to invent another language. Oh, I know about the CPython solutions on Android, like Kivy and PyQt. It was interesting for me to consider how to construct applications that don't rely on native libraries to run, or the Android SDK/NDK to build. It was interesting to see that projects like Androguard had already done a lot of this before. I chose to try and do something with a Python-like language because it's familiar to me. The modules that the compiler uses are more likely to be useful to people, especially those doing Jython-like solutions for Android, though I realise that going via Java bytecode rather than direct to Dalvik is the preferred route. David From david at boddie.org.uk Tue May 17 15:43:16 2016 From: david at boddie.org.uk (David Boddie) Date: Tue, 17 May 2016 21:43:16 +0200 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: Message-ID: <201605172143.16777.david@boddie.org.uk> On Tue May 17 15:15:04 EDT 2016, Joao S. O. Bueno wrote: > The point of the toolset David just borught up is not just about 'an > entire oher language' - it is a toolset for being able to manipulate > android assets, and that is in Python. I would also recommend that people look at Androguard as well, since it supports all kinds of things that I wasn't interested in. https://github.com/androguard/androguard/ I didn't reuse any of it because it seemed that it has a different goal to the one I was aiming for, which was to be able to create Dalvik bytecode in a high level language and package it up. > And the new language, that comes up for free, is different from Kivy > and other approaches, in the sense it compiles python-like source ode > directly to Dalvik bytecode - it is not the same as(1) building Python > natively on Android, and not the same as emulating Python over Java. Emulating Python on Java would be interesting if you wanted to get the behaviour of the code as close as possible to CPython. I wonder if it would be possible to target Dalvik with RPython - I've never looked at RPython closely. > I don't think replying to someone who is bringing a totally cool, > months long project, with lots of tools, innovations and possibilities > with "you could have used X" is anything constructive - at least not > if one does not at least take a look on what is being presented. I'm sure that Bill wasn't trying to be unconstructive, just trying to prevent someone from doing unnecessary work. After all, I did say that I got into doing this because I wanted to learn about developing for Android, and this probably isn't the most optimal way of doing it, though it is interesting! > I don't think Kivy is good for getting performatic, or native-looking > apps, when talking about Python, for example. And also, the tools to > handle android assets in this repo could even be used to replace the > need for Android SDK when building Kivy based apps. What I found interesting about Java and Android development was that the way the SDK does things is the way everyone thinks you _have_to_ do them. Once you have tools to assemble packages, you can use OpenSSL to sign them, and that removes the need for things like keytool and jarsigner, which are part of the JDK. In practice, you still need things like adb if you want to look at logs, but maybe that could also be reimplemented. However, it's not currently on my list of things to do. David From gabriel.pettier at gmail.com Tue May 17 18:23:10 2016 From: gabriel.pettier at gmail.com (Gabriel Pettier) Date: Wed, 18 May 2016 00:23:10 +0200 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: References: <201605171805.51312.david@boddie.org.uk> Message-ID: <20160517222309.GA19588@king> One limitation we didn't work around yet with pyjnius, and that is quite painful on android, is that JNI doesn't provide a way to extend a class, and it's painful because a lot of the android API requires you to do precisely that, in such case the way to do it is to do a java class for the part that requires it, and then use this class from pyjnius, but it's not very nice to have to jump to java often if you use a lot of the android api that requires that. Another way I toyed with (quite some time ago) was to automatically generate utility classes, that allowed you to implement an interface instead of extending a class (the generated java class would call code from your implementation in its overriden methods), but failing to find a way to generate a whole set of the possible classes you'd need to generate the android api, i put that aside and never really came back to it. Another possible solution was suggested recently, which was using bytebuddy [1] to generate the classes you'd need, i didn't explore this track, since i'm not currently focused on android stuff, but that could be a nice way to work around the issue. [1] http://bytebuddy.net/ @david: thanks for sharing, that does look nice, and as was said, even parts of it could maybe help us to do a better usage of android assets formats, so thanks again for sharing :) On Tue, May 17, 2016 at 07:18:01PM +0200, Dima Tisnek wrote: >How about python-java bridge, like Rubicon or pyjnius? > >You get best of both worlds -- a good language and a mature runtime. >On 17 May 2016 18:05, "David Boddie" wrote: > >In a belated attempt to jump on the Android bandwagon I started to look >into learning Java and the Android APIs. I realised very quickly that I >couldn't face writing a lot of code in that language. Looking around for >other languages running on the Dalvik VM, I found a few that might be nicer >than Java, but I wasn't so sure that I wanted to write in any of those, >either. > >In the end, I decided to try an experiment to see how much I could learn >about Dalvik and Java by creating tools to handle some of the file formats >used in Android packaging, and by trying to implement a compiler for a >subset >of Python. > >The result can be found in this repository: > > https://bitbucket.org/dboddie/duck > >It should be noted that the source language isn't really Python. The parser >from the standard library is used to parse it, but the semantics of the >generated code are different to those of Python. That's why I gave the >language a different name. > >How is this relevant to a mailing list about Python on mobile platforms? > >Firstly, the language may be close enough to Python for people to find it >more familiar than Java, even if there are places where the differences may >trip them up. Writing code to fit into a framework designed for a statically >typed language requires a slightly different mindset to the one you might >have when writing regular Python code, so it may not seem so strange to >developers once they've accepted that. > >Secondly, it makes it possible to write a more faithful implementation of >Python using code that looks a lot like Python, instead of Java. You could >use it to write support code for a compiler, or perhaps write an interpreter >in it. > >It's all very experimental at the moment. I've been uncomfortable about >publishing it before now because I keep finding things I've overlooked, >though it's been a good learning experience. Maybe there will be things in >there that people find useful. > >David >_______________________________________________ >Mobile-sig mailing list >Mobile-sig at python.org >https://mail.python.org/mailman/listinfo/mobile-sig >_______________________________________________ >Mobile-sig mailing list >Mobile-sig at python.org >https://mail.python.org/mailman/listinfo/mobile-sig -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From russell at keith-magee.com Tue May 17 18:29:33 2016 From: russell at keith-magee.com (Russell Keith-Magee) Date: Wed, 18 May 2016 06:29:33 +0800 Subject: [Mobile-sig] Fwd: Experiments with Dalvik In-Reply-To: References: <7809.1463510191@parc.com> <201605172126.17409.david@boddie.org.uk> Message-ID: Hi David, On Wed, May 18, 2016 at 3:26 AM, David Boddie wrote: > On Tue May 17 14:36:31 EDT 2016, Bill Janssen wrote: > > > In case you weren't aware, you can just write Android apps and services > > in Python, using Kivy. No need to invent another language. > > Oh, I know about the CPython solutions on Android, like Kivy and PyQt. > It was interesting for me to consider how to construct applications that > don't rely on native libraries to run, or the Android SDK/NDK to build. > It was interesting to see that projects like Androguard had already done > a lot of this before. > > I chose to try and do something with a Python-like language because it's > familiar to me. The modules that the compiler uses are more likely to be > useful to people, especially those doing Jython-like solutions for Android, > though I realise that going via Java bytecode rather than direct to Dalvik > is the preferred route. > > This is a really interesting approach - thanks for sharing. I?ve been doing something similar recently with VOC [1]. I?m targetting Java bytecode rather than Dalvik, but with a similar end goal: to take Python source code, and deploy it to Android as a native application without needing to use the Android NDK. A couple of weeks ago I published a video showing a native iOS, Android and single-page web app, all doing the same thing running on Python [2], using this toolchain (plus some other tools). Of course, you?ve got the added bonus that you don?t need the Android SDK either, which would be a huge win in my book. What?s the impact of Android?s move to ART on this approach? [1] https://github.com/pybee/voc [2] https://www.youtube.com/watch?v=RisCgSIWwLA Yours Russ Magee %-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From russell at keith-magee.com Tue May 17 18:31:33 2016 From: russell at keith-magee.com (Russell Keith-Magee) Date: Wed, 18 May 2016 06:31:33 +0800 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: <20160517222309.GA19588@king> References: <201605171805.51312.david@boddie.org.uk> <20160517222309.GA19588@king> Message-ID: On Wed, May 18, 2016 at 6:23 AM, Gabriel Pettier wrote: > One limitation we didn't work around yet with pyjnius, and that is quite > painful on android, is that JNI doesn't provide a way to extend a class, > and it's painful because a lot of the android API requires you to do > precisely that, in such case the way to do it is to do a java class for the > part that requires it, and then use this class from pyjnius, but it's not > very nice to have to jump to java often if you use a lot of the android api > that requires that. For the record - VOC handles this with relative ease. Yours, Russ Magee %-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.kolman at gmail.com Tue May 17 20:39:06 2016 From: martin.kolman at gmail.com (Martin Kolman) Date: Wed, 18 May 2016 02:39:06 +0200 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: <20160517222309.GA19588@king> References: <201605171805.51312.david@boddie.org.uk> <20160517222309.GA19588@king> Message-ID: Wed, 18 May 2016 00:23:10 +0200 Gabriel Pettier: > One limitation we didn't work around yet with pyjnius, and that is > quite painful on android, is that JNI doesn't provide a way to extend > a class, and it's painful because a lot of the android API requires > you to do precisely that, in such case the way to do it is to do a > java class for the part that requires it, and then use this class from > pyjnius, but it's not very nice to have to jump to java often if you > use a lot of the android api that requires that. Another way I toyed > with (quite some time ago) was to automatically generate utility > classes, that allowed you to implement an interface instead of > extending a class (the generated java class would call code from your > implementation in its overriden methods), but failing to find a way to > generate a whole set of the possible classes you'd need to generate > the android api, i put that aside and never really came back to it. > Another possible solution was suggested recently, which was using > bytebuddy [1] to generate the classes you'd need, i didn't explore > this track, since i'm not currently focused on android stuff, but that > could be a nice way to work around the issue. > > [1] http://bytebuddy.net/ Another possibility (and what I'm doing) is to use use PyOtherSide (which can be used on Android[0]) and use the Android API over the interface provided by Qt/QML[1]. While not all of the Android API is covered, many of the Qt APIs (such as location ,sensors, etc.) are cross platform, so if you are also doing a cross platform application you don't need to special case for Android so much. And if you *do want* to special case/make and Android only application Qt seems to have some sort of mechanism for interacting with the Android Java code[2]. Even though that interface is in C++, it can be easily exported to QML and then used from Python via PyOtherSide. [0] http://pyotherside.readthedocs.io/en/latest/#building-for-android [1] http://doc.qt.io/qt-5/android-support.html [2] http://doc.qt.io/qt-5/qtandroidextras-module.html > > @david: thanks for sharing, that does look nice, and as was said, even > parts of it could maybe help us to do a better usage of android assets > formats, so thanks again for sharing :) > > On Tue, May 17, 2016 at 07:18:01PM +0200, Dima Tisnek wrote: >> How about python-java bridge, like Rubicon or pyjnius? >> >> You get best of both worlds -- a good language and a mature runtime. >> On 17 May 2016 18:05, "David Boddie" wrote: >> >> In a belated attempt to jump on the Android bandwagon I started to look >> into learning Java and the Android APIs. I realised very quickly that I >> couldn't face writing a lot of code in that language. Looking around for >> other languages running on the Dalvik VM, I found a few that might be >> nicer >> than Java, but I wasn't so sure that I wanted to write in any of those, >> either. >> >> In the end, I decided to try an experiment to see how much I could learn >> about Dalvik and Java by creating tools to handle some of the file >> formats >> used in Android packaging, and by trying to implement a compiler for a >> subset >> of Python. >> >> The result can be found in this repository: >> >> https://bitbucket.org/dboddie/duck >> >> It should be noted that the source language isn't really Python. The >> parser >> from the standard library is used to parse it, but the semantics of the >> generated code are different to those of Python. That's why I gave the >> language a different name. >> >> How is this relevant to a mailing list about Python on mobile platforms? >> >> Firstly, the language may be close enough to Python for people to >> find it >> more familiar than Java, even if there are places where the >> differences may >> trip them up. Writing code to fit into a framework designed for a >> statically >> typed language requires a slightly different mindset to the one you >> might >> have when writing regular Python code, so it may not seem so strange to >> developers once they've accepted that. >> >> Secondly, it makes it possible to write a more faithful >> implementation of >> Python using code that looks a lot like Python, instead of Java. You >> could >> use it to write support code for a compiler, or perhaps write an >> interpreter >> in it. >> >> It's all very experimental at the moment. I've been uncomfortable about >> publishing it before now because I keep finding things I've overlooked, >> though it's been a good learning experience. Maybe there will be >> things in >> there that people find useful. >> >> David >> _______________________________________________ >> Mobile-sig mailing list >> Mobile-sig at python.org >> https://mail.python.org/mailman/listinfo/mobile-sig > >> _______________________________________________ >> Mobile-sig mailing list >> Mobile-sig at python.org >> https://mail.python.org/mailman/listinfo/mobile-sig > > > > _______________________________________________ > Mobile-sig mailing list > Mobile-sig at python.org > https://mail.python.org/mailman/listinfo/mobile-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at boddie.org.uk Wed May 18 18:06:14 2016 From: david at boddie.org.uk (David Boddie) Date: Wed, 18 May 2016 23:06:14 +0100 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: References: <7809.1463510191@parc.com> <201605172126.17409.david@boddie.org.uk> Message-ID: <4be2bd210af452e19ff5f90483878458@webmail.webfaction.com> On 2016-05-17 23:04, Russell Keith-Magee wrote: > This is a really interesting approach - thanks for sharing. You're welcome. I hope it helps to provide new insights into the other approaches people are taking. > I?ve been doing something similar recently with VOC [1]. I?m > targetting Java bytecode rather than Dalvik, but with a similar end > goal: to take Python source code, and deploy it to Android as a native > application without needing to use the Android NDK. A couple of weeks > ago I published a video showing a native iOS, Android and single-page > web app, all doing the same thing running on Python [2], using this > toolchain (plus some other tools). That should be interesting to see. I don't have much time to look at it this week, but I'll try to make some time after the weekend. > Of course, you?ve got the added bonus that you don?t need the > Android SDK either, which would be a huge win in my book. What?s the > impact of Android?s move to ART on this approach? The first thing I checked was whether ART makes work done for Dalvik obsolete. According to the following document, it shouldn't have any obvious effect: both use Dex files and Dex bytecode. https://source.android.com/devices/tech/dalvik/index.html If I was writing anything complex enough then perhaps I would run into differences. Currently, I'm testing on a fairly old Android device. I may well buy something running an up-to-date version to test on, and a tablet might be interesting given that I don't really want to start collecting phones. I'd be interested in receiving suggestions for any that are reasonably priced, have unlockable bootloaders, and whose manufacturers supply the source code that they are supposed to for system components. I realise that I may have narrowed the field a bit with those requirements. ;-) David From russell at keith-magee.com Wed May 18 22:15:09 2016 From: russell at keith-magee.com (Russell Keith-Magee) Date: Thu, 19 May 2016 10:15:09 +0800 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: <4be2bd210af452e19ff5f90483878458@webmail.webfaction.com> References: <7809.1463510191@parc.com> <201605172126.17409.david@boddie.org.uk> <4be2bd210af452e19ff5f90483878458@webmail.webfaction.com> Message-ID: On Thu, May 19, 2016 at 6:06 AM, David Boddie wrote: > On 2016-05-17 23:04, Russell Keith-Magee wrote: > > This is a really interesting approach - thanks for sharing. >> > > You're welcome. I hope it helps to provide new insights into the other > approaches people are taking. > > I?ve been doing something similar recently with VOC [1]. I?m >> targetting Java bytecode rather than Dalvik, but with a similar end >> goal: to take Python source code, and deploy it to Android as a native >> application without needing to use the Android NDK. A couple of weeks >> ago I published a video showing a native iOS, Android and single-page >> web app, all doing the same thing running on Python [2], using this >> toolchain (plus some other tools). >> > > That should be interesting to see. I don't have much time to look at it > this week, but I'll try to make some time after the weekend. If you?re coming to PyCon US, I?ll be speaking about this work. If you?re not? well.. the videos will be online shortly after, I suppose :-) > Of course, you?ve got the added bonus that you don?t need the >> Android SDK either, which would be a huge win in my book. What?s the >> impact of Android?s move to ART on this approach? >> > > The first thing I checked was whether ART makes work done for Dalvik > obsolete. According to the following document, it shouldn't have any > obvious effect: both use Dex files and Dex bytecode. > > https://source.android.com/devices/tech/dalvik/index.html > > If I was writing anything complex enough then perhaps I would run into > differences. Currently, I'm testing on a fairly old Android device. > > I may well buy something running an up-to-date version to test on, and > a tablet might be interesting given that I don't really want to start > collecting phones. I'd be interested in receiving suggestions for any > that are reasonably priced, have unlockable bootloaders, and whose > manufacturers supply the source code that they are supposed to for > system components. I realise that I may have narrowed the field a bit > with those requirements. ;-) My current test setup is a Nexus 5 I inherited from my father-in-law, plus an older Kogan Agora phone: https://www.kogan.com/au/kogan/shop/phones/android/ (That?s the Australian store; The Kogan phones are the usual ?cheap manufacture and rebrand? devices - the same device is sold by a couple of other companies in Australia under different brand names. For the price, they?re pretty good as test devices. They don?t make a big deal about getting access to the boot loader and system software, but I know some people at Kogan, and they?re generally sympathetic to FOSS (they?re a well known Django shop); I?ll give them a poke and see what they say about releasing technical details. Yours, Russ Magee %-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at boddie.org.uk Thu May 19 17:47:48 2016 From: david at boddie.org.uk (David Boddie) Date: Thu, 19 May 2016 22:47:48 +0100 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: References: <7809.1463510191@parc.com> <201605172126.17409.david@boddie.org.uk> <4be2bd210af452e19ff5f90483878458@webmail.webfaction.com> Message-ID: On 2016-05-19 03:15, Russell Keith-Magee wrote: > If you?re coming to PyCon US, I?ll be speaking about this work. If > you?re not? well.. the videos will be online shortly after, I > suppose :-) I'll be sure to check those out. :-) > My current test setup is a Nexus 5 I inherited from my father-in-law, > plus an older Kogan Agora phone: > > https://www.kogan.com/au/kogan/shop/phones/android/ > > (That?s the Australian store; > The Kogan phones are the usual ?cheap manufacture and rebrand? > devices - the same device is sold by a couple of other companies in > Australia under different brand names. For the price, they?re pretty > good as test devices. They don?t make a big deal about getting > access to the boot loader and system software, but I know some people > at Kogan, and they?re generally sympathetic to FOSS (they?re a > well known Django shop); I?ll give them a poke and see what they say > about releasing technical details. That would be good move in general, I think. I'd never heard of Kogan and the site keeps wanting me to go to the /au/ pages, so I wonder if they still have a presence outside Australia. It's always interesting to see what there is on offer, anyway. David From dimaqq at gmail.com Fri May 20 03:08:20 2016 From: dimaqq at gmail.com (Dima Tisnek) Date: Fri, 20 May 2016 09:08:20 +0200 Subject: [Mobile-sig] Experiments with Dalvik In-Reply-To: References: <201605171805.51312.david@boddie.org.uk> Message-ID: Apologies if my response came out negative. First off, big ups for fresh toolchain! Let me clarify my world view: I believe in Python, which means Android running full-fledged cpython or pypy, including running Python code from source (for development at least), and python runtime / stdlib (obv. some system restrictions apply). Beyond that, I believe that Android runtime (UX, UI, hw access, IPC, etc.) is the way to go. That means no Qt or any other "native" 3rd party libs. There are tools to bridge the two, and there's where I hope to see progress. I like what you've done with Duck, I especially like Android type annotations. Perhaps it's possible to integrate this syntax into plain Python program using only decorators and metaclasses, that is running your syntax with cpython. Cheers! On 17 May 2016 at 19:18, Dima Tisnek wrote: > How about python-java bridge, like Rubicon or pyjnius? > > You get best of both worlds -- a good language and a mature runtime. > > On 17 May 2016 18:05, "David Boddie" wrote: > > In a belated attempt to jump on the Android bandwagon I started to look > into learning Java and the Android APIs. I realised very quickly that I > couldn't face writing a lot of code in that language. Looking around for > other languages running on the Dalvik VM, I found a few that might be nicer > than Java, but I wasn't so sure that I wanted to write in any of those, > either. > > In the end, I decided to try an experiment to see how much I could learn > about Dalvik and Java by creating tools to handle some of the file formats > used in Android packaging, and by trying to implement a compiler for a > subset > of Python. > > The result can be found in this repository: > > https://bitbucket.org/dboddie/duck > > It should be noted that the source language isn't really Python. The parser > from the standard library is used to parse it, but the semantics of the > generated code are different to those of Python. That's why I gave the > language a different name. > > How is this relevant to a mailing list about Python on mobile platforms? > > Firstly, the language may be close enough to Python for people to find it > more familiar than Java, even if there are places where the differences may > trip them up. Writing code to fit into a framework designed for a statically > typed language requires a slightly different mindset to the one you might > have when writing regular Python code, so it may not seem so strange to > developers once they've accepted that. > > Secondly, it makes it possible to write a more faithful implementation of > Python using code that looks a lot like Python, instead of Java. You could > use it to write support code for a compiler, or perhaps write an interpreter > in it. > > It's all very experimental at the moment. I've been uncomfortable about > publishing it before now because I keep finding things I've overlooked, > though it's been a good learning experience. Maybe there will be things in > there that people find useful. > > David > _______________________________________________ > Mobile-sig mailing list > Mobile-sig at python.org > https://mail.python.org/mailman/listinfo/mobile-sig From david at boddie.org.uk Fri May 20 17:42:32 2016 From: david at boddie.org.uk (David Boddie) Date: Fri, 20 May 2016 22:42:32 +0100 Subject: [Mobile-sig] Experiments with Dalvik Message-ID: <658d0033b00941ae530e60c661213d4d@webmail.webfaction.com> On Fri May 20 03:08:20 EDT 2016, Dima Tisnek wrote: > Apologies if my response came out negative. > > First off, big ups for fresh toolchain! No worries. I'm not trying to sell a particular solution to anyone, and I know that not everyone will want to follow the path I'm on. > Let me clarify my world view: > > I believe in Python, which means Android running full-fledged cpython > or pypy, including running Python code from source (for development at > least), and python runtime / stdlib (obv. some system restrictions > apply). > > Beyond that, I believe that Android runtime (UX, UI, hw access, IPC, > etc.) is the way to go. That means no Qt or any other "native" 3rd > party libs. > > There are tools to bridge the two, and there's where I hope to see > progress. It's good that you have specified what you are looking for. I think that there are lots of different ideas about what would be the right solution for Python users, but different users have different requirements so there will never be one perfect solution. For example, if someone wants to do cross-platform mobile development, they may want something like Qt to abstract away the details of the platform to some extent. That will never be satisfactory to someone who wants to be exposed to the platform API with nothing in the way. Obviously, I'm less bothered about using something other than CPython or PyPy. If something is close enough to the core Python language then it's probably good enough for me. I am a fairly conservative user of language features. :-) Hopefully, there will be at least one solution for each of the use cases that people have for Python on Android so that everyone can find something that meets their needs. > I like what you've done with Duck, I especially like Android type > annotations. > Perhaps it's possible to integrate this syntax into plain Python > program using only decorators and metaclasses, that is running your > syntax with cpython. Thanks. I hoped the syntax annotations might make people think about how types are declared in Python, if you need to declare them. They are a bit like the slot declarations in PyQt and I would like them to be optional in the case where it should be obvious that a method is a reimplementation of a method in a base class or interface. I thought about writing some kind of framework that lets CPython run the annotated programs but it sounds like a lot of work to sort out things like method overloading. My brother put in a lot of effort to handle this kind of thing in his javaclass Java classfile loader for Python, which means that I've heard enough about the problems involved to want to avoid them. :-) David