These are chat archives for pybee/general

12th
Aug 2016
Russell Keith-Magee
@freakboy3742
Aug 12 2016 01:13
@astocks No particular preferred solution - anything that works and is reasonably efficient is fine.
Johannes Tandler
@jotdl
Aug 12 2016 09:12
Hi everybody, I just came across your awesome support repositories in order to build python for Android and iOS. But then I noticed that you guys mainly work on voc (https://github.com/pybee/voc) at the moment. Because I am doing some research about cross platform scripting at the moment I am very curious about your reasons to abandon these support repositories (at least the android one) in favour of building voc. I think building a cross-compiler from one language to another one is mainly for performance improvements, isn't it? But, if you do not cross compile to a multiplatform language, supporting multiple platforms becomes a lot harder due the need of writing two cross-compilers, doesn't it? Because Java can not be executed on iOS it seem's like that you have to build another tool now, in order to get iOS working the same way as voc works for Android, right? Otherwise it looks for me like nobody can ensure that python stuff on iOS and Android really behave the same way, because in one way python is interpret by CPython and the other way it's cross compiled into java byte code. What were your reasons to start voc and do I miss something here?
Adam Stocks
@astocks
Aug 12 2016 09:17
I think this link might help. http://pybee.org/project/using/
You can see the differences between iOS and Android.
I'm brand new to the project so can't help much, but hopefully that's a start.
Johannes Tandler
@jotdl
Aug 12 2016 09:32
Thanks for you help :smile: Those pages show that on android everything is crosscompiled and iOS is interpret by CPython. Sadly I could not find any points why VOC (and all the effort to realise and maintain it) is the preferred solution in comparison to using the same approach on Android as on iOS (interpret python with CPython).
Russell Keith-Magee
@freakboy3742
Aug 12 2016 13:07
@jtandler The major problem with the CPython approach on Android is the bridging layer. If you just want to run Python, CPython embedding is fine; but if you’re writing an Android app, you probably want to display widgets on the screen etc, and Android doesn’t expose those through a C api - it’s a Java API.
Adam Stocks
@astocks
Aug 12 2016 13:08
good morning @freakboy3742 . Having fun at djangocon?
Russell Keith-Magee
@freakboy3742
Aug 12 2016 13:09
If you use embedded CPython, that means you have to use JNI to bridge between CPython and the Java runtime - which works, but has some serious performance problems. Most significantly - you need a JNI reference for every class, instance, method, & argument that you use in your app - and you need approx 4000 of those to fully instantiate the classes involved in a basic Hello World. However, Android enforces, at the kernel level, a 2000 reference limit on JNI (and on some Android devices, it’s even lower - but you can’t find that out until it breaks)
On top of that, JNI reference lookup is fairly slow. All this adds up to the fact that you don’t get good performance using CPython over JNI. Slow app startup, and laggy performance overall.
VOC enables you to build directly into Java, producing output that is completely native Java bytecode, yielding all the benefits of Java’s JIT, and providing native access to all the Java classes. Although it seems like a lot more work, the result works a lot more smoothly.
@astocks Good morning! Yes, DjangoCon AU went very well. Getting ready for 2 days of PyCon AU now :-)
@jtandler As a side effect, VOC isn’t Android specific. It enables you to run Python code anywhere that Java is the only (or preferred) runtime environment. That means Minecraft server plugins; IDE plugins for PyCharm or Eclipse; J2EE deployments; Swing apps, and more.
Johannes Tandler
@jotdl
Aug 12 2016 14:56
@freakboy3742 Thank you very much for your detailed anwser! Didn't know that about JNI on Android! But from this point of view, I really understand your decision. Those things don't sound like a nice software development environment. But all your points are about Android and the JNI itself. Do you consider going the same way for iOS as well or will you stick with the CPython approach there?