by rtpg · 10y ago · 0 comments
Google should be spending millions being able to get app development up and running in something like Python. Have your app up and working in 2 minutes without having to learn Java. It boggles the mind that this isn't the case, and that the current tooling environment is soooo impossible to wrap ones mind around.
Transpiling languages like that nearly always ends up messy, and adds another layer of potential bugs to the system. Taking the time to learn the platform will end up better in the long run (at least with the current state of transpilers).
And as it stands, you can write Android apps with a native UI in Java, Kotlin, JS (React Native) and C# (Xamarin). And you if you want you can write business logic using any language that will compile to a C binary (using the NDK).
In order to get any access to the Android APIs, you have to do C-JDK bridging through JNI. And in android VMs, there's a hard limit on the number of symbols you can reference in the lifetime of an app.
It's the equivalent of if python was like "yeah you can use the standard library, but only up to 100 functions!"
iOS, since it goes through the LLVM framework stuff, doesn't have that many barriers to transpiling from other languages. You can just do raw function calls to the OS libs. But Android doesn't allow this, forces you to go through the JNI, and makes you have to work around this symbol limit.
I've found, from experience[1], that large code bases written in statically typed languages like Java tend to be much more easier to read, understand -- which is extremely critical when working with a team. I use Python for a lot of my personal projects, but for a team project, I would rather use Java than Python.
[1] Explained in detail here: https://news.ycombinator.com/item?id=12594616
If you want to use Python and native UI components at the same time, you must run Python as a kind-of backend layer, where you call JNI functions from Java which will be redirected to the Python interpreter through C/C++. I have done this with an app that I have on the Play Store [2] which shares all non-UI code with a web app [3]. Even the charts are similar as they are generated as SVGs on my Python code.
This architecture allows me to have native frontends on different platforms, and I have open-sourced PyBridge [4] to be used as starting point for everyone who wants to use something like this: basically, you send JSON messages from Java to Python with the name of a function and the arguments, and you get the response.
[2] https://play.google.com/store/apps/details?id=com.flatangle....