Thursday, April 15, 2021

Flutter, Python, and which to use for what

Recently, I have started learning how to program user interfaces in Flutter (which is based on the Dart language). It is different from other programming languages and GUI frameworks which I have used in the past. In this post, I am going to talk a bit about my thoughts on Flutter/Dart and Python (with frameworks like PySimpleGUI and Kivy).

A bit of background. I am new to Flutter and Dart. I have been using Python for several years (since 2016) with some experience in the GUI frameworks wxPython, Kivy and PySimpleGUI. I have also done programming in Java before (back in the early 2000s, as well as in recent years). I have tried to learn wxWidgets in C++. In the 1990s, I have used C to program text-based applications and for micromouse. I learnt Turbo Pascal in school, and before that, I picked up C on my own, and even before that, I have programmed in GW-BASIC and Quick BASIC. When I was working in data science, I picked up R too.
 
I like Python for its ease of use. It is a high level programming language with a lot of libraries that can make life very easy for the programmer. You can probably find a library that does what you want to do without having to do everything from scratch. And it is easy to use these libraries too, since they are usually available via a central repository. Flutter/Dart also has a good central repository of packages too, and the selection covers a broad scope. But still, compared to Python, Flutter/Dart does not have that extensive a selection.
 
This makes Python very attractive when I need a quick solution. Find the libraries I need, piece them together to achieve the solution I want, and voila! While Kivy is not an easy GUI framework to use, PySimpleGUI allows me to easily clobber together a GUI for the underlying application. And if I am doing something related to data science, Python is really convenient because many of the needed data manipulations are available in easy-to-use libraries.

The issue is deployment. I have written about two methods: using PyInstaller, and using Cython. (These are for deployment to Windows, which is still what the majority of consumers use.) While both methods are not exactly rocket science, it still requires some effort on the programmer to write configuration files (for PyInstaller) or figure out which are the DLLs you need if using Cython.
 
Flutter makes deployment much easier. There is still the need to edit the build configurations, but I find it to be much less complicated (okay, this is subjective). You can easily package for Linux using snapcraft. Packaging on Windows is easy if you use Inno Setup. And packaging for Android is easy too, just use flutter build android. And Flutter's UI consistency across different platforms makes it truly attractive when building cross-platform applications. Kivy tries to achieve the same for Python, but I found it hard to change the default Kivy theme.

In summary, I prefer Python when I need something to be done without having to worry about deployment. So I use Python when I am working on applications that I intend for my own personal use. For applications that will likely be useful to more people, I intend to use Flutter/Dart going forward due to its consistency cross-platform look and well-documented steps for platform deployment.

----------------
Side note: I continue to use C/C++ for microcontroller programming since that is usually the language that most microcontrollers' frameworks support. MicroPython is up and coming too. Given that Python and Flutter/Dart both can run on different platforms, I no longer find Java, which I once preferred for its cross-platform features, attractive. I still have fond memories of BASIC but that is more for nostalgia than practical use. I was never fond of Pascal and only used it because school assignments required me to do so. I haven't touched R ever since I left my full-time data science job.

No comments: