4 ms·
Without a miracle, it seems like a bit of a lost cause. I see some pretty glaring reasons why Python has not taken off in writing GUIs, especially on mobile.
by microcolonel 11y ago
Without a miracle, it seems like a bit of a lost cause.
I see some pretty glaring reasons why Python has not taken off in writing GUIs, especially on mobile.
1. The Python runtime is not very easy to embed on iOS and Android, and the sheer number of bindings needed to make it worth doing is immense.
2. Python's runtime is completely and utterly incapable of threading. Threading being almost essential to any decent user interface, this whole idea falls flat.
3. If the other two problems weren't enough, Python's single-threaded performance is really not great either. On resource-constrained systems (think phones) this hits doubly hard.
- wiz21 11y agowho said Python mus be running client side ?
- matjazzz 11y agoI wouldn't agree on points 2 and 3. I find multiprocessing routines really easy to implement and they work as they should. However, I have no experience with threading in other languages so I might be missing out ... With regards to performance, I found that one can produce very fast routines through use of specialized libraries for specific tasks, such as numpy etc. There are also great visualization tools, such as pyqtgraph which are blazing fast, at least, in my view, compared to any web interface. I have been skeptical about the html/js interface so far, because I am concerned with how fast large amounts of data can be surfaced from Python data models to HTML plots. That said, I share the Python UI pain :/ As of now, I am stuck with QT and cx_freeze for desktop app development and the whole thing feels very medieval. The QT library in itself is great but at the same time it does not feel very "python". cx_freeze requires constant tinkering and makes debugging very hard at times. What do HN users use for building GUIs for Python? :)
- nzjrs 11y agoI use gtk via pygobject. I find it feels the most pythonic. Cross platform remains difficult however.
- infinite8s 10y agoWhile it feels more pythonic, it does not look at all native on most platforms.
- tluyben2 11y ago1. Using the work done by the Kivy guys fixes that need; you can easily run on mobile. With a native webview on both you can use OP his new and shiny GUI browser framework from Kivy without much issue.
- notzorbo3 11y ago> Python's runtime is completely and utterly incapable of threading. Threading being almost essential to any decent user interface, this whole idea falls flat. This is just plain wrong and the fact that many GUI programs are written in Python (dropbox, NetworkManager, Zim desktop wiki, etc) should be evidence of that. In fact, most people don't even realize these are written in Python. Yes, Python has the GIL. No, that does not mean it can't do multithreading. It merely means it can't do parallel processing on multiple cores with just threading. But that is by no means a requirement for multithreading, especially regarding GUIs.
- shoyer 11y ago> 2. Python's runtime is completely and utterly incapable of threading. Threading being almost essential to any decent user interface, this whole idea falls flat This simply isn't true. Python has the GIL, but that doesn't stop it from making use of threads for IO or CPU bound tasks that release the GIL (using extension modules). There are lots of libraries for multi-threaded IO in Python (e.g., gevent, Twisted, Tornado, asyncio), and, not surprisingly, they are very widely used for web programming.
- toyg 11y agoGlossing over the threading misinformation, Python's requirements are not particularly different from the likes of C#, but unlike C# there is nobody with the commercial incentive and necessary scale to do the hard work. The only platform where Python could flourish without effort was Maemo, and for the very brief time that project lived, it did exactly that.
- zeveb 10y ago> 2. Python's runtime is completely and utterly incapable of threading. Threading being almost essential to any decent user interface, this whole idea falls flat. While you're AFAIK correct about running Python on mobile devices, and I think anyone will admit that Python's performance has never been great, one can have a great UI without threads: use coroutines and channels instead. Fortunately, Python does have coroutines, and a channel library can be built in the fashion of Lua's channel library (https://github.com/majek/lua-channels https://github.com/majek/lua-channels). I don't know if anyone has done it yet, I'll grant, but a cursory look suggests that it's possible. The basic idea is that one would spawn a coroutine to handle each UI element, and the coroutines would send messages to one another on channels. I've no idea how fast it would be (at a guess: terrible), but it should work.