BeeWare – write Python, run everywhere using native UIs
beeware.org
beeware.org
This is my favorite video by Russel [0], it really is a fascinating project, and he is a great speaker.
With that said, I don't really see it becoming a widely used framework. No matter how creative the solution is, it's hard to compete against real native, Kotlin Multiplatform Mobile, Flutter, React Native, Electron, and more. The most complicated example I saw with BeeWare is a todo list app [1]
[0] https://www.youtube.com/watch?v=qaPzlIJ57dk [1] https://www.youtube.com/watch?v=RisCgSIWwLA
* pyjs / pyjamas
* brython
* kivy
* chaquopy
* pyqt
* pygtk
* ...
But the first big problem has always been delivering an experience that looks and feels right on the target platform. Do you use the native UI or do you use something else? The swing Java UI's of the 00's were so kludgy, and looked unprofessional because they implemented their own UI components.The other big problem is that how does the code run? Is it transpiled to javascript or does it have to download a python interpreter that can run in the browser/android? It's not a big issue for like a native app for mac/windows, but for the browser it is. https://brython.org takes ~6 seconds to run a simple clock because it's downloading the interpreter. Wasm doesn't necessarily help here, since either you compile the code to directly run on wasm, or you need to bring along the wasm compiled interpreter.
An example of this is Jython. It needed to start the JVM, then run the python code in the python interpreter in the JVM. Very inception like, though I did enjoy writing unit tests this way. Mostly because unit tests didn't need to be compiled against a jar. And broken unit tests didn't need a full recompile.
Compose desktop currently target the JVM, which of course is not going to work on IOS. They do use Skia for the UI; which is also what Google is using with Flutter, I think.
Targeting the Kotlin native compiler would be a logical next step. It's currently quite usable for porting libraries between different platforms. However, I'm guessing they would need to do a bit of work on improving the multi platform library ecosystem to be able to have enough of a base platform for developing full applications with it. Targeting IOS would be a logical next goal once they are able to do that.
I have nothing against Javascript but there are still a lot of weird limitations in RN despite being several years old. Writing smooth animations that support user interaction is difficult because it is still single threaded and you are limited to a declarative animation api where the underlying native runtime does the interpolation.
React-reanimated v2 tries to solve this by spawning JS worklets that can run animation code in another thread but that comes with its own caveats. This would be so much easier to do in a language with built in threading, not to mention all these languages are very ergonomic and loved by developers so I'm curious why something similar hasn't been tried for them yet.
Why react-native, well, because it means you have access to one of the largest ecosystems and an awesome tooling catalogue. The same applies for JS as the language of choice for App (UIs). Kotlin was also a great candidate since it could leverage the already mature Java ecosystem for android.
Flutters success is an outlier here that I would guess is due to Google backing. The resources and docs are good and you could rely on financial and developer backing. The decision to go with Dart was most likely to make themselves not dependent on another party for a core utility and to have a steering position on the overall projects course.
If, for example, Microsoft would back a good C# cross-platform framework I would bet on it at least seeing moderate adoption.
Edit: As another commenter pointed out, GO has a cross-platform GUI Framework option - Fyne [https://github.com/fyne-io/fyne]
I want to try out Flutter, but my main target is Web and Desktop apps (Recent update from Flutter for Windows Desktop Apps made me want to learn it)
I have heard several criticisms regarding flutter for Web, that bundle sizes are high and load times are slow.
What is your opinion? How was the experience, and most importantly, is designing apps with flutter easier on the cognitive side?
Flutter on the web looks like Flash, everything feels very off, scrolling, keyboard support, text selection, etc everything just feels strange or doesn't work and it provides a poor end user experience.
Apart from the good mobile experience, I'm also excited about Flutter on desktop. It might not be "there" yet (I don't know, I am not using it in production), but it's promising and could be a good alternative to native desktop development and Electron.
Just don't expect to use it for an E-Commerce site or something like that.
Do you love Dart though? Flutter's stateful hot code reload is amazing but, man, for me Dart is just completely hideous. Maybe I've gotten spoiled by Typescript and Scala...
Does it stranspile to JavaScript, or compile to asm, or something else entirely?
You can learn more about the status quo here https://dart.dev/web
Compiling to WASM is on the roadmap https://github.com/flutter/flutter/wiki/Roadmap#dart
> Dart (...) We also plan to expand Dart's compilation toolchain to support compiling to Wasm, contingent on the timely standardisation of WasmGC.
The Dart team is investigating a dart-to-wasm compiler, but is waiting on the Wasm GC proposal to be standardized: https://medium.com/dartlang/experimenting-with-dart-and-wasm...
I was a big fan of some of the early Dart leaders (Lars Bak and Gilda Bracha). I remember when I asked why Dart seemed like a watered down variant of some Lars and Gilads earlier work; I was tiled by a former colleague that had joined the project that “Lars was playing it safer, playing to win” these days.
I don’t know how much either of these people are associated with Dart anymore. Somewhere in Dart’s search of a killer problem to be the solution for, we got fully typed Dart (as opposed to the original annotations are optional mindset).
I did one of the free web courses for it, built like 10 teeny pointless apps. Three things stood out:
- the experience was kind of painful on iOS, the look had an “uncanny” effect
- the tutor tried to explain classes as a “way of organizing code” which undersells what classes are really about (binding behavior to data)
- the language felt like an alter Java (type declarations in the left side still??)
For a UI framework, there is a distinct lack of screenshots.
> > So, why is it called "Toga"?
> When in Rome, do as the Romans do. And what does a Roman wear? A Toga!
Ha, that's a clever choice.
Yeah. I was able to find some here; looks clean and reasonable at least on Mac:
https://twitter.com/PyBeeWare/status/1366274894967709702/pho...
https://maestral.app/assets/images/screenshot.png
(I'm including the Maestral link because one of @pybeeware's tweets says that Maestral is a BeeWare app)
https://docs.beeware.org/en/latest/_images/tutorial-5-launch... https://docs.beeware.org/en/latest/_images/tutorial-5.png
> From its probable beginnings as a simple, practical work-garment, the toga became more voluminous, complex, and costly, increasingly unsuited to anything but formal and ceremonial use. It was and is considered ancient Rome's "national costume"; as such, it had great symbolic value; however even among Romans, it was hard to put on, uncomfortable and challenging to wear correctly, and never truly popular. When circumstances allowed, those otherwise entitled or obliged to wear it opted for more comfortable, casual garments.
> ... the toga's bulk and complex drapery made it entirely impractical for manual work or physically active leisure. The toga was heavy, "unwieldy, excessively hot, easily stained, and hard to launder".[39] It was best suited to stately processions, public debate and oratory, sitting in the theatre or circus, and displaying oneself before one's peers and inferiors while "ostentatiously doing nothing".[
Beeware – Android and iOS Apps in Python - https://news.ycombinator.com/item?id=24487867 - Sept 2020 (25 comments)
BeeWare project: A request for your help - https://news.ycombinator.com/item?id=14034353 - April 2017 (1 comment)
Build and ship native GUI apps on Python with Beeware [audio] - https://news.ycombinator.com/item?id=12719433 - Oct 2016 (6 comments)
BeeWare: The IDEs of Python - https://news.ycombinator.com/item?id=12374952 - Aug 2016 (1 comment)
BeeWare – The IDEs of Python - https://news.ycombinator.com/item?id=9616641 - May 2015 (28 comments)
It's got some very similar features to BeeWare and the author is on Hacker News somewhere...
Though I am excited to try out beeware again.
> $5000/month
> An annual meeting with core team
I understand that these are technically "donations" but the incentives offered are very much just a lightweight support agreement for 2-10x the price.
I have no reason to believe that a python based UI solution that finally captures some market share could be a big success, and are that point the pseudo donation model would go out the window. Best of luck to these guys, would be cool to not be forced to use TKinter in school assignments.
I could hire a contractor to build out all the UI in whatever framework I want. Plus I avoid paying someone to build it + pay for the framework.
BTW, I've used QT4 in the past with python and it was an absolutely dream to work with. In 2 months part time work, I was able to produce a very high quality app that worked on windows, linux, macos. Highly recommend instead of TK.
But after spending the same amount of time with QT it definitely won out.
I used pyQT (python bindings for QT) + I believe PyInstaller (https://pyinstaller.readthedocs.io/en/stable/) for building the executable. Was a very pleasant experience!
Especially since it is open source. You would only be paying to have your name listed, and have some direct influence on the direction on the project.
I mean, the KV language is pretty neat, but the insane amount of tooling involved (that always, always fails) to actually open your app on your phone is disgusting. Disgusting as in using three different versions of Python, setting up mismatching Android tooling, cross-compiling wheels on your virtual machine only for it to fail with some cryptic GCC error disgusting. It's also pretty outdated (e.g. camera doesn't work properly with the last ~5 Android APIs), and of course very slow, even if you pre-optimize your code with pagination and stuff.
Kinda regret using Kivy at all, despite its community being amazing. So, can't recommend. Perhaps, you could consider learning Flutter instead? It will take just about the same time investment, but the whole experience is incomparable. Even better, make a test app in Kivy, and then make one in Flutter. (This is only partly a joke, though. It's really that fun.)
They seem under-resourced, though, especially BeeWare. Targeting platforms that do not support python natively feels like a task that would challenge even much larger teams
"On desktop platforms (macOS, Windows, Linux), any pip-installable can be added to your requirements. On mobile platforms, your options are a little more limited - you can only use pure Python packages i.e., packages that do not contain a binary module.
This means that libraries like numpy, scikit-learn, or cryptography can be used in a desktop app, but not a mobile app. This is primarily because mobile apps require binary modules that are compiled for multiple platforms, which is difficult to set up.
It’s possible to build a mobile Python app that uses binary modules, but it’s not easy to set up – well outside the scope of an introductory tutorial like this one."
I had the same issue when investigating Kivy and PyQt. It definitely seems possible since you can download Pydroid [1] for android (that supports e.g. pyqt, opencv, tensorflow) or Pyto [2] for iOS (that seems actually is based on BeeWare and support many non-pure modules including opencv)
[1] https://play.google.com/store/apps/details?id=ru.iiec.pydroi...
Am I an outlier, or is it this difficult to get working at first? I imagine that once you get a working build, it must work quite smoothly!
I start with a release of WinPython, then use its command line to make a virtual environment, install `briefcase` and go from there.
I should also add that I found FMan's Build System to be quite easy to do the same thing: https://github.com/mherrmann/fbs-tutorial
Windows is the absolute worst for packaging Python (unless you give up and package everything in a self-extracting exe, but then antivirus is even more likely to eat it) and Android barely runs native Qt (seriously, the demo project from their website straight up doesn't build), so I can imagine that running something with 4 layers of stuff in between would have even worse odds of working.
https://beeware.org/contributing/challenge-coins/
I'm glad to see it's still going, I'm going to try it out again.
Does anyone know how well this performs on windows.
The get going story seems MUCH improved for python though which is interesting. https://doc.qt.io/qtforpython/quickstart.html
Still a bit pricey to just play around with building something I think for someone small? But at least it's simpler, I could see buying something now - before it was impossible.
I never really got into QML (javascript type language). I'm not sure QT creator let's you form build with python? Downloading it is an evaluation thing as I look at it.
I was looking at Fyne for doing desktop UIs in Go: https://github.com/fyne-io/fyne
I can keep everything in the Go ecosystem that way.
Any thoughts or advice?
I like the guys behind BeeWare and they've done some very good work to address the awful Python story on mobile, but every time I try BeeWare it lacks a lot of functionality one would expect from production-ready toolkits. I'm sure things will improve with time, but I have a feeling someone with deeper pockets will eventually eat their lunch.
https://github.com/fyne-io/fyne
scroll down for some screenshots.
Make a runtime that can run a bunch of quasi-native code and make it download code from URLs and execute that.
The experience for the user would be to type "myapp.com" on the URL bar and then get a full native app running inside that browser window -- except instead of bloated JavaScript it would be this new language thing with more powerful native-like APIs and without 32 years of bloated history on its back.
I'm sorry if this is too confusing.
3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded
You would have to ship a new copy of it with each application.
Your idea sounds really interesting, but I imagine it being hard to combine the two different frameworks. Especially UI elements.
The number of convoluted JavaScript "data" apps that I've replaced with python and just a dash of Pandas is too high.
I mean, it's somewhat more suited to data crunching ...
I wonder if the significant increase of Python users lends well to it being also usable as a UI tech with the advantage merely being familiarity, consolidation of tech (i.e. 'we only use Python in house, no need for JS' etc..
Web is different for many reasons and there Python does well.
(Submitted title was 'BeeWare – write Python, run as native everywhere')
https://toga.readthedocs.io/en/latest/background/philosophy....
Native GUI frameworks can be more of a challenge. Still, if you want a native L&F your alternative is to code each platform individually, then something like this (or wxWidgets/SWT/etc.) is likely to be a lot less work (but likely to look a bit less native). Trade offs. Good to have choices I think.
It's very strong for the many "good enough" scenarios that range from complete products in domains like pharma where users will tolerate user experience glitches as long as they can be using the same Pandas code behind the scenes on multiple OSes, or utility-level apps that need to run on multiple platforms. These are often tucked away in places that HN readers are averse to exploring from a career perspective.
The toolset for "Write once. Deploy everywhere." that works is HTML + JS + CSS and nothing else. This is because browsers work about the same everywhere.
IMHO if an app is not going to leverage the platform but will simply show some UI to display or collect data, the way to do it is HTML + JS + CSS in the browser.
When you try to support platform specific features, you end up doing much more work but instead of working on the primary App, you spend you time on integration and replication of platform behaviour or functions.
> that works is HTML + JS + CSS and nothing else.
That type of UI mostly works for "reader" applications - when maximum what you do is clicking on buttons and filling couple of <input>s.
For "creator"'s applications, CADs, editors, IDEs, and so on, HTML + JS + CSS is far from being perfect. At least without special means that extend these technologies to acceptable level.
Menu shall be menu but not that position:absolute something, dialog shall be modal window, drawing shall support immediate mode, keyboard interaction shall be there, and so forth.
I think that’s possible when the App and user interaction model is completely custom - like shooting zombies or drawing 3D shapes.
That's also party why browsers can't replace every app(the browsers have it's own opinion about the UI and interactions), the other reasons are performance and access limitations.
There are a lot of very high quality libraries like Pandas and SciPy that are not available in the React Native ecosystem. Tools like those provided by BeeWare let you add a GUI quickly. The folks interested in interacting with something running on these data science libraries tolerate imperfect user experiences more than the average consumer.
If we looked at React Native we could level your argument at it as well. Why use RN when you could build real native apps? Surely, that's the most optimal experience over a third-party platform, no matter how good RN is in practice.
csharp and java, famously interpreted languages, unlike javascript.
Seeing as this is for GUIs and not say, computing digits of Pi, I think Python is a fantastic choice for this.
I honestly wish Python had taken off as the web language instead of JS, but that's a conversation for another time.
FWIW, I'm not a Python fanatic or anything, I haven't used it in years - but it's hard to argue it's not a great language for beginners.
Sarcasm?
Typescript tries to fix a lot of the problems JS has, but still inherits a lot of its problems.
> especially when you consider the insane performance compared to Python
In my experience, people who complain about Python’s performance don’t actually have experience with software optimization. Aka, the same people who decide to use C++ “because fast”.
Even if you only look at synthetic benchmarks, there is not a single thing that would make javascript stand out as a good choice for high performance computing, V8 or not. But even if you find yourself in a situation where you’re stuck with javascript and have to optimize a particularly nasty hot path, the types of techniques you’d need to rely on aren’t going to be all that different than what you’d have to do with Python (with similar results).
The difference is that the Python environment can almost always outsource processing to a C library (maybe even hand written assembly). That’s really only possible with typescript if you’re working with Node, but I don’t think that’s what you’re referring to considering the context of this thread.
> and the fact that it can run in the web.
AKA, the only reason to use Javascript pre-Node. Post Node, you get to share code throughout your whole stack, but even then that’s rarely the best objective choice, and the benfits of using a single language tend to be overblown in my experience. For example, an Elixir/Erlang backend would be overwhelmingly more beneficial to any project than the minor conveniences of a single language (and I think Erlang is even slower than Python)
When/if web assmebly becomes more popular, I think JS/TS will finally die because web developers will finally be exposed to good languages, and will not want to go back to the mess that JS is/was.
And why would Python level "slow" matter at all for most kinds of apps? You're not writing games or bitmap editors with this...
I should also add that it is GPL - with all that implies. They also have commercial licenses.
Instead, what I think we need is a solid cross platform native UI library targeting C (libui would be a candidate - before it lost momentum). It would then be a reasonable amount of work to create multi-language bindings. Instead we have things like wxWidgets/Qt that are a pain to create bindings for since it is written in C++. As proof this would accelerate things, notice how many languages have GTK bindings (C based).
As a user, I don't want to use toy applications. So hats off to those who do things properly and use the real platform frameworks.
Kotlin/Rust could be supported if there's enough interest.
Plus there are actual companies putting continued investment into V8 and react native, since their revenue depends on it. Python is a liability when it’s used in anything other than developer tooling.
Everything in Python feels like it was made by some passionate oss devevelopers. Cool stuff, but not sustainable or ergonomic. The type system is kludgier than typescript’s and not as strong as rust’s. Python’s async APIs are embarrassing compared to JavaScript’s.
Sadly this feels like one of those projects that should have been abandoned or pivoted before sinking so much energy into it.
I love Python and still use it all the time. But for anything UI related I stay away.