Thanks in part to the rise of machine learning, programming language Python is hugely popular with developers, but so far mobile devices have been no place for Python applications.
Yet Python creator Guido van Rossum and some Python developers hope that apps written in Python may one day run natively on iOS and Android devices. That could happen thanks to BeeWare, an open-source project headed up Russell Keith-Magee, which is porting CPython to Android, so apps written in Python can run natively on Android.
In February, Keith-Magee announced the project's first major Android milestone after getting a 'pure' Python application to run on an Android device. He gave an update at the 2020 Python Language Summit, which was held online this year due to the coronavirus pandemic.
SEE: Six in-demand programming languages: Getting started (free PDF)
BeeWare is aiming to let developers write apps in Python and get that code running everywhere using user interface (UI) widgets. It wants to help developers write Python apps using the same codebase running on iOS, Android, Windows, macOS, Linux, browsers, and tvOS.
CPython is the reference implementation of the open-source Python language used by other implementations such as Jython, which is written in Java that relies on a Java virtual machine (JVM). But Python is not cut out for mobile in the way it has been for desktop systems.
To address this shortcoming, last year the Python Software Foundation awarded the BeeWare project a $50,000 grant to bring its level of Android support up to par with its tools for iOS. The CPython Android port would have to support most modern Android hardware running version 4.4 or later.
"BeeWare's Android strategy was to compile Python to Java bytecode, but Android devices are now fast enough, and the Android kernel permissive enough, to run CPython itself," said A Jesse Jiryu Davis, an engineer at MongoDB and a Python contributor.
Davis said a major obstacle was the size of Android apps written in Python because they require their own copy of the Python runtime, meaning Python needed to be shrunk down for mobile.
Some have suggested solving this problem by creating a stripped-back 'kernel' version of Python – an idea that Keith-Magee believes could solve many Python mobile challenges, in combination with a package installer (pip) that lets developers install packages for a target platform rather than just the system it's running on.
"To regular Python programmers, the mobile environment is an alien planet," explains Davis. "There are no subprocesses; sockets, pipes and signals all behave differently than on regular Unix; and many syscalls are prohibited.
"TLS certificate handling on Android is particularly quirky. For the CPython test suite to pass on mobile, it must skip the numerous tests that use fork or spawn, or use signals, or any other APIs that are different or absent."
Keith-Magee reckons more mature Android support means CPython contributors "can have a serious conversation about how we get these changes merged into CPython itself". So now the question is whether CPython developers will be interested in bringing mobile Python into the core.
The good news is that van Rossum has endorsed mobile support in the long term, according to Davis.
But there are big obstacles. According to Ned Deily, a Python core developer at PSF, delivering mobile support will require more money and people than many other Python initiatives.
On top of this, Davis notes that Python has a chicken and egg problem on mobile: "There is no corporate funding for Python on mobile because Python doesn't support mobile, so there is no one relying on mobile Python who is motivated to fund it."