Live data from Hacker News

Ask HN: How do you create a cross-platform GUI without using Electron?

news.ycombinator.com

31–40 of 112 posts

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#31
I've successfully built apps with Python and Qt (PyQt6 and PySide6 are both working fine). The overall file size of the resulting folder is about 60-80 MB on Windows, mostly due to all the Qt DLLs/plugins you'll need to ship. By manually deleting non-necessary DLLs, you might save maybe up to 20 MB. Just considering the file size, this might not a huge gain compared to Electron, I suppose?

However, keep in mind that desktop apps have the major disadvantage of figuring out distribution (separately for each platform!!), which includes the following two steps: 1) packaging the application in some format (e.g. an MSI installer for Windows and a Disk Image Bundle for macOS), and 2) distributing that package (including auto-updates). I have written a number of articles about this topic, see https://www.augmentedmind.de/2021/05/30/distributing-windows... and https://www.augmentedmind.de/2021/06/13/distributing-macos-a... . You get rid of all that if you just built a PWA or other kind of web app.

In addition, if you use Python, you also need to choose a "freezing" solution, such as PyInstaller (more details at https://www.augmentedmind.de/2021/05/16/distribute-python-ap... ).

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#32
post #23

I personally like wxWidgets: https://www.wxwidgets.org/ It's open source, the code has always felt reasonably clean to me, and it gives your apps native look and feel.

I second this choice. It is the only toolkit that looks native in Windows.

And it is ridiculously fast compared to alternatives.

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#33
I use Delphi with its FireMonkey framework. It targets all major operating systems (Win/Lin/Mac/Droid/iOS) natively. From all the cross-platform frameworks that I've seen in 25+ years of working in the industry Delphi's switching target is the easiest - a simple combobox and kaboom!, you're good to deploy for that OS.

Their roadmap include, in some years I suspect, probably 5, to also target WASM at which point, if Embarcadero is smart enough to lower their ridiculous license pricing to under $300, will become the most powerful tool to write cross-platform applications.

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#34

Delphi, believe it or not. Might even be the most mature and feature-rich of any of the technologies and frameworks mentioned here. RAD Studio 11 just got released and allows native development for "all platforms" from a single codebase and GUI at the click of a button. [0] I have ranted about and harshly criticised Embarcadero's misguided product policies as much as the next guy but that doesn't change the fact that…

Have you tried Free Pascal with Lazarus[1]? How does it stack up compared to Delphi?

[1] https://www.lazarus-ide.org/

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#35

https://tauri.studio/ - I haven’t used it myself but looks pretty interesting. They say they use existing browser engine shipped with OS and desktop integration layer written in Rust. The claim is that you get an application size under 1MB

Can you share any insight in the cross-os implementation inconsistencies of those browser engines?

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#36
post #9

I'll get shot for suggesting this most places, but I feel like GTK has the most 'native' feel across every operating system. That's not to say that it's easy to get working (setting up proper build targets is going to be your biggest hurdle), but your reward is a stylish and robust UI with proper touchscreen support on Windows/Linux.

GTK doesn't look native in KDE, yet QT looks more native in Gnome.

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#37
post #7

There are several options, each with their own pros and cons. Qt [1] The main codebase is C++, but bindings are available for Python and several other languages. I have developed and shipped multiple cross-platorm applications using Qt, using both C++ and Python. Documentation and source code examples are readily available. JUCE [2] Another C++ framework, with Python bindings. The focus is on music and audio apps, bu…

Is there a good grid control (ie a data grid) for Blazor? A colleague reviewed the offering from Infragistics and it wasn't anywhere near their WPF data grid control.

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#38
One word: Lazarus.

Cross platform done right (native code, no intepreter, no VM). Both IDE and generated code run native just about everywhere, from small ARM boards to virtual machines, and of course x86. As fast as C, decent sized executables, lots of built in or available libraries and components to do a lot of things, from managing databases to low level access to hardware, graphics, sound, etc. And of course it's 100% FOSS.

My last use case was a few years ago when a friend needed to monitor some security cameras, but they were of different brands and needed either their crappy Android/iOS app or a even more crappy XP-only ActiveX control on Internet Explorer, while he wanted to monitor them from a single screen on a Windows 7 PC. As soon as I discovered the right URL for each one to grab their video feed, I arranged a window container in Lazarus dropping there a bunch of media player components, each one linking to a camera, a few other controls and bingo, he could fire up the application and have the mutiple camera view on a monitor.

If it compiled more modern languages such as Nim, Rust or Crystal it would be perfect, but even by current standards Object Pascal it's still really powerful.

https://www.lazarus-ide.org/

https://wiki.lazarus.freepascal.org/Screenshots

https://wiki.freepascal.org/Projects_using_Free_Pascal

https://www.devstructor.com/index.php?page=tutorials

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#39

https://tauri.studio/ - I haven’t used it myself but looks pretty interesting. They say they use existing browser engine shipped with OS and desktop integration layer written in Rust. The claim is that you get an application size under 1MB

Can you share any insight in the cross-os implementation inconsistencies of those browser engines?

Not a front end developer, and I do not know much about it, but I imagine that native engines would be Edge on Windows 10, Safari on iOS and whatever is installed on Linux by default - usually Firefox. From here you would need to figure out the differences between those engines with something like caniuse. Like support for service workers etc.

Re: Ask HN: How do you create a cross-platform GUI without using Electron?

#40
It depends. I've built a lot of these. The best approach is to keep the UI very lightweight and just build it using native controls for each platform. Keep all the application logic in a common library and just rewrite the parts that are interactive. This isn't as much work as it seems, especially if you design it upfront, and there's no other way to get a native feel. There's also some "product management" advantages to this approach, such as building new features first on your smallest platform so you can test/iterate quickly with few users and then moving them to Windows when they are proven. Don't build new features on all three at once, take turns.

If the app has a whole lot of dense UI screens, or if you don't particularly care about it looking nice and feeling platform native, something like Qt or many of the other frameworks suggested here work well, but do be aware that you'll be making it harder to use platform features. For example, on MacOS you wouldn't support the TouchBar and would have some extra complexity to support Metal graphics vs GL (which Qt supports).

You can also do something similar to Electron but much more lightweight using a platform WebView. Then you can have common controls built in a htmlish way, and still have custom and native controls mixed in. One example of an app I worked on that was built this way and worked well was an app to browse/view 100s of video clips, we had a common html-based widget to filter and display search results and thumbnails (which had a bunch of interesting layout requirements) but the video playback itself was in a native panel (it needed to play custom formats so using web for everything wasn't appropriate).

Flutter looks promising but it still feels a little early. Try it out if you're willing to take some risks and maybe bend your thinking a bit. I found it too indirect and felt like I had to give up too much design responsibility to the toolkit when I last tried it but maybe that's an advantage.

If you're thinking about Electron, why not make it a purely web app? Then you'll save yourself lots of hassles distributing and downloading.

Also, for graphically intensive or in-house tools (like a game level editor) i use Dear ImGui, it's very fast to develop and great cross platform support, but I wouldn't ship it to a customer.

Post reply on HN