by petargyurov · 6y ago · 0 comments
I think the problem here is two fold: bad UIs and bad APIs. In the science world, there doesn't seem to be any abstraction between backend and frotnend -- the whole thing is one intertwined mess.
Scientists don't always write great software; they write scripts that get the job done quickly in a very specific way. Pair that with the lack of time that they have to wrap things in a GUI and you get a Tkinter/Qt app that is unmaintanable.
I'm currently volunteering with the NZ Department of Conservation. Here is a tiny preview [0] of an app that I have just started making for them. It's purpose is to aid scientists with processing camera trap images using machine learning. I'm building the UI using ElectronJS and Svelte, whilst the backend is a separate Python project.
I know the fad these days is to turn everything into a web app but my experience working with Qt really just demonstrated to me that a lot of web UI development is reinventing wheels from desktop UI but poorly and with more bugs and frustration.
That's just my perspective though :-)
I recently spent a year working on a Qt app for drawing circuit diagrams, aimed at nuclear engineers. I've lost count of the number of times I found myself wishing for some feature that React has implemented for years.
The parts of the code that were easiest to maintain were the ones that reinvented reactive UI: every modification to the underlying data called some "updateGraphicsView" function that would then re-render the entire thing. Not great for performance, great for avoiding bugs.
Seriously, for me Qt goes in the "never again" category.
Thanks for sharing this. I have a relatively simple Python script that I'm trying to package for a non-technical Windows user so, as someone whose experience skews toward web development, your comment caught my attention.
I just googled "electron svelte python" and found this write up:
https://medium.com/@abulka/electron-python-4e8c807bfa5e
Which references this Github repo:
https://github.com/fyears/electron-python-example
It all sounds pretty brittle. How are you managing communication between your ElectronJS frontend and Python backend? Any references you recommend?
As far as I understand, there are two ways to handle communication between the Python and ElectronJS:
1) Use inter-process communication. Basically, your Python app outputs to stdin and your Electron app consumes the output. Also works the other way. This is what I went with.
2) Use a Flask (or equivalent) local web server and have your app send requests to it.
I find method 2) a bit hacky and unintuitive for a desktop app. If you are planning on hosting your backend in the cloud this would be a decent solution, but I am not.
I had already done some work to turn my Python app into a standalone CLI tool using `click` [0] which made the interaction with ElectronJS very simple. I used `python-shell` [1] for the inter-process communication. I do think that I might not need this once I package my Python app into an .exe -- then Electron should be able to interact with it in some way without caring that it's built in Python.
You can take a look at my repo here, though it's still in its infancy: https://github.com/petargyurov/megadetector-gui
Nonetheless, is a great project and not so difficult to use, although not perfect, it worked perfectly for our needs.
> I sent an email to a specific conservation project, asking if they happen to need any software help at the moment and they did. We got chatting, agreed on some goals and I got working. I signed their volunteer agreement form which sets out some conditions (nothing unsurprising). That's it really.
For what it's worth I am not even based in NZ; I'm in the UK. Happy to chat in more detail if you want to know more (my email is in my profile)
After that I want to give the user an easy interface for training their own models (transfer learning using an existing base model).
What makes you say that it isn't getting traction? AFAIK, some huge companies are using it to create their apps.
I think it gets a lot of underserved hate, just because it's JS and because it isn't "truly native". People also love to chime in about its performance but 9/10 times that's down to a bad implementation, in my humble opinion.
The main advantages (over executing your app in-browser) to my knowledge:
1. You can execute native code outside normal browser sandbox
2. You get your own application window