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

92 points by mariocesar ↗ HN
I have the idea of an app that is mostly about communicating with an API on the WEB. It feels a considerable overkill for an Electron App. The size of a hello world app in Electron is 100x the size of my backend!

On the business side, I understand that many people on HN prefer to ship that spend time on technologies discussions.

But if you have the time, and your goal is to do something maintainable, reasonably close the most to the Desktop, and well-integrated to the OS, what tech/stack will you use?

Windows/Linux GTK/MacOS

111 comments

[ 5.3 ms ] story [ 169 ms ] thread
Is there a particular language that you needed to use or have skills in? That's a very important qualifier.
Python, JavaScript a little of C, and similars
So in Python, you can use Qt but I am not sure how their licensing works. You can give Tkinter a try in Python since it's a "default". Also there's Kivy but I don't have experience in that.

As for Javascript, you can use Electron or React Native but I don't know how far along React Native on the desktop is compared to Electron.

Hope that helps and someone may come along that could speak in more depth on one or more of these packages for your use case.

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, but a cross-platform GUI framework is also part of the library.

Blazor Desktop [3]

I have developed C# web applications using Blazor and WASM and moved them to the desktop easily. Using C# and the Dotnet ecosystem is really interesing and worth looking at.

Flutter for Desktop [4]

Still in beta, but has the support of Google, for better or worse.

JavaFX [5]

A Java cross-platform still under active development. I think it is pretty nice if you like Java.

Red [6]

Let's add an outsider just to keep things interesting!

This github site seems somewhat current about other Electron alternatives as well. [7]

Good luck! You will find there are lots of alternatives out there.

[1] https://www.qt.io/

[2] https://juce.com/

[3] https://visualstudiomagazine.com/articles/2021/02 /17/net-6-preview-1.aspx

[4] https://flutter.dev/desktop

[5] https://openjfx.io/

[6] https://www.red-lang.org/p/about.html

[7] https://github.com/sudhakar3697/electron-alternatives

If you have access to Python 3.5 or 3.6, you can use my open source library https://build-system.fman.io to create a Python / Qt app with an installer for all the OSs in minutes. Python 3.7-3.9 is also supported, but only available commercially.
I am really looking forward to the day that I can build cross-platform GUI apps in Red. Based on Rebol, it is a beautiful yet powerful language. They are always looking for more contributors, if anyone is interested.

Here's an example of what it could do on macOS four years ago: https://www.red-lang.org/2017/07/063-macos-gui-backend.html

Edit to add: You can build cross-platform GUI apps in Red now but, while they're very close to the finish line, and making progress every day, there are still a few missing pieces yet to complete on the 1.0 roadmap.

Vote for Flutter and QT
Why is flutter better than electron?
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.
There are grid controls from the usual commercial vendors like Radzen and Telerik. I used them briefly during a free trial. It has a funny name, but MudBlazor [1] has been the MIT licensed library I have been using lately. I have been using their Table control, which may be what you are looking for in a data grid. [2] Check it out and see.

[1] https://mudblazor.com/

[2] https://mudblazor.com/components/table#api

From https://juce.com/get-juce "JUCE is dual licenced under both the JUCE licence and the GPLv3."
Pricing isn't too bad if you don't want to go the GPL route.

If your funding or revenue is $50k and under, there is no cost, but there is a "Made with JUCE" splash screen.

If your funding or revenue is $500k and under, $800 one time fee and there is no splash screen.

You can pay $2600 once with no revenue or funding limit and no splash screen.

Free for education.

Funny, I actually use JUCE for audio and yet it never crossed my mind to use it as a general purpose cross platform UI. Good call!
any good open source one?
godot: https://godotengine.org/ most of godot UI itself is made with godot engine
I'm thinking of using godot for the GUI on a decently complex Windows application. I'm concerned that Microsoft is no longer interested in desktop applications and I don't want to embark on something that has no long term future.
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.
I personally think the exact opposite. GTK needs a lot of custom styling to get the "native" style to work, and even then it's kind of lacking.

GTK feels right at home in the GNOME desktop environment (which I use, and like!) but for cross platform I don't really think it feels native at all. As a user, I've had much better native experiences with QT or WxWidgets to be honest (on Windows, at least).

GTK doesn't look native in KDE, yet QT looks more native in Gnome.
> but I feel like GTK has the most 'native' feel across every operating system

That's not true since GTK3, where GTK started to look like GTK regardless of the platform.

I recently built one using Fyne for golang. It works well for my case but Fyne is still very new and in development.

http://fyne.io/

Qt/QML is my choice.
It would be really nice if there was a shared widget API that would work for the major operating systems. If most of simple app could work on Windows, OSX, maybe mobile (Android / iOS) and Linux / BSD.

Something that was mostly native for all of them.

Currently the only alternative to Electron that is similar is a program that hosts a local webserver and the local browser is pointed at it, but that's a second class experience.

(comment deleted)
I think wxWidgets fills this role pretty nicely. It's what, e.g., Audacity and FileZilla use.
My biggest criticism is more that the widgets library really should already _be_ there, and ideally updated automatically, on a client's system.

Hello World (GUI) shouldn't be a 50MB deliverable. If I'm providing someone with a toaster I shouldn't have to ship a whole mobile home. Nor should that end user need to park 300 mobile homes on their hard disk.

There are other criticisms about wxW in specific linked from the wikipedia page... https://en.wikipedia.org/wiki/WxWidgets#Criticism

Dolphin's is illustrative of the pain involved in using that widget set. https://dolphin-emu.org/blog/2017/06/03/dolphin-progress-rep...

I'm not the best person to explain or recommend it, but I'll suggest "immediate mode" GUIs partially because I want to hear more about the pros/cons from those more experienced (I haven't ever worked on UIs professionally). It seems these graphics libraries just need some kind of context to draw to, like from OpenGL, and also have a simpler implementation in general. That might make them more portable and smaller, if less native-feeling. I just started looking into egui (a Rust crate) myself.
I love IMGUIs but you have to be careful with the to get them to play nice with the event loop. If you're using it for a game where you're drawing every frame anyways, they're great. But for something that the user might keep running alongside other apps they can be a cpu/memory hog. You can of course only process/redraw when an event happens but that can be easier said than done sometimes.
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.
Used this for a small linux GUI proof-of-concept.

I really liked it. It was awesome to use something I'm familiar with (Next.js) and have it drive the UI. Resulting application was indeed about 1MB after all said and done.

Interesting, but say good by to consistency across platforms.

The whole reason electron was created is because using a random unknown browser on the OS has random results.

You probably are wasting your time - multi-billion dollar companies have abandoned native desktop development - pretty sure they decided it was just easier and cheaper to maintain. If you are doing this for fun or profit - you need to decide how much your time is worth.
There is also an interesting solution to this problem: use native WebView, so you don't have to pack the whole Chrome with your app. Basically every "electron alternative" with HTML+CSS+JS works this way.

https://github.com/sudhakar3697/electron-alternatives

You'll have a little bit more testing to do, as the web-views shipped by different OS might not be exactly in sync feature wise, but if your app is really simple it shouldn't be much of a problem.
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.

I'm currently writing a cross-platform toolkit, and I'd like to know what native looks like in Windows. As far as I can tell it's worse than Linux. You have the old Win32 / MFC style widgets, and programs like Notepad++ that use something that looks similar. There's the style that much (but not all) of the Control Panel seems to use (is the name Metro?), but the only application that I've used that uses anything similar to that is the Edge browser. There's also the MS Office style, but that seems like a one-off, except that Explorer seems to use it. I've heard things about WFC, which seems to be deprecated, no idea what it looks like. I really dislike the Windows experience, so I have limited recent experience since I avoid using it as much as possible, but so far every application I've used looks different.

I'd like to know what the "native experience" is supposed to be, but I have no idea which of the numerous Microsoft UI APIs is officially current. So far I've just punted and I'm using macOS shapes and sizing and using the colors from the Metro? style; at least it will look tasteful and not stand out too much color-wise.

> You have the old Win32 / MFC style widgets

That's the one. Everything else has never gained enough traction.

Windows 8 really broke the UI, to support tablets, and the OS has never recovered. :(
Tauri looks promising if you can code Rust
Sciter [1] is kind of a really lightweight electron. It's about 8Mb, cross platform, and you can either run it standalone (like electron) or use it as a library from Rust/D/Python/C#/whatever. You pay for the small size with a lack of compatibility with the existing Javascript ecosystem. Any moderately complex JavaScript library that interacts with the dom will probably use something that Sciter doesn't implement, so you end up reimplementing stuff like graph libraries. On the other hand there are a couple of very useful additional APIs that regular browsers don't have (like SQLite, control over window borders, transparent windows etc).

1: https://sciter.com/

I'd highly suggest using Dart and Flutter.

I've probably written GUI apps in C, Java, Ruby, Objective-C, Swift, JavaScript, and probably a couple I forgot about. Dart+Flutter come the closest to being "good" and correct. There's some missing documentation for Desktop development with regards to Flutter + Dart but nothing is totally intractable if you're willing to read through issues. My only caveat is that Google is truly an awful company to depend on for your business; since, they 100% do not give a a single fuck about you unless you're paying them ~$100 million or more a year, or an EXTREMELY high profile client.

I've been getting ready to give Pascal a solid try but I still totally lose my mind when working in Lazarus (like where did the thing I just used go? Ah yes, tiny, free-floating window, of course). I have a feeling Pascal is probably the real diamond in the rough of UI application development these days.

Qt is probably fine but their licensing turns me off from ever using or considering it.

Qt has been mention a lot, it's confusing all the license deal. I kind of understand that is free of use if it's not embedded.

But flutter looks like a good option.

> Qt is probably fine but their licensing turns me off from ever using or considering it.

If I may ask why? They provide GPL and LGPL, and this last one is quite permissive.

See: https://www.qt.io/licensing/open-source-lgpl-obligations

> In case of dynamic linking, it is possible, but not mandatory, to keep application source code proprietary as long as it is “work that uses the library” – typically achieved via dynamic linking of the library. In case of static linking of the library, the application itself may no longer be “work that uses the library” and thus become subject to LGPL. It is recommended to either link dynamically, or provide the application source code to the user under LGPL.

Doesn't Flutter fail point 1: all widgets are custom rendered (OpenGL) things? So integration with the host OS's capabilities may be lacking (e.g. accessibility features).
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 Delphi is still the most mature and versatile Rapid (sic) Application Development environment out there, especially if UX and UI are important to you.

And the twenty-year old adage that you can knock out an MVP with a really nice and polished GUI in a Saturday afternoon is now even more true than ever.

In the end, a native binary with a small footprint (easily 1/100th the size of an Electron project) will fall out at the press of the F9 key and that's really something to behold...

The free Delphi community edition [1] might even offer all the features that you need, although I really wish Embarcadero would see the light already and sync its release cycle with the full version.

Delphi might not officially be regarded as hip or cool these days (mostly due to severely and ongoing errant product and community management by the company that makes it) but some great people and brilliant minds are associated with it and compared to the olden days Delphi is now somewhat of a secret underground Swiss army knife that ironically gets used now mainly in big and medium corporations.

I like to think its versatility combined with the fact that it's technically uncool and against the mainstream to do projects in Delphi these days might fit a hacker's (and HN user's) mindset very well...

[0] https://www.embarcadero.com

[1] https://www.embarcadero.com/products/delphi/starter?aldSet=e...

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

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

I like Lazarus and I think it's great and important that it exists, especially with Embarcadero refusing to recognise and take seriously the needs of a developer community outside of Fortune 500 orgs (I'm slightly exaggerating but not much).

Lazarus is Free Software, which is awesome, and its feature set is also mature and impressive (I wouldn't have thought that the project also has a 20+ year history already).

I do recommend it highly if you can't get your hands on Delphi, don't want to support Embarcadero's antics, or work with an open-source project anyway. Several major component developers, including the great guys at TMS with their cloud pack and Raspberry Pi components [0] make a ton of awesome components that are available for both Delphi and Lazarus and I can highly recommend them.

If you're operating in the commercial space and have a budget, a bigger team, strong network, database or certain other commercial requirements, you might appreciate the support options and greater choice of 3rd party components which can be installed in Delphi with just a click and that save just so, so much time in getting your product to market.

If you're learning or teaching the language, working in a small team or alone, or require a feature set fully supported by Lazarus or just like free software, I wholeheartedly recommend Lazarus as a great alternative indeed. If you're somehow in the middle, check out the Delphi Community Edition too and just find out what suits you better. I guess it also comes down to what you're used to...

[0] https://www.tmssoftware.com/site/products.asp?t=lcl

> take seriously the needs of a developer community outside of Fortune 500 orgs

Yeah no kidding. Last year I tried to download the trial of their paid C++ IDE. The licensing tool wouldn't work, and support never returned my emails. People complained in the official forum, no company response their either. I took that to mean "We see you as such a low-value potential customer, we won't lift a finger to get our own demo to work for you".

Does the community edition work on linux, or compile to linux? The page says:

> Delphi Community Edition is a full featured IDE for building iOS, Android, Windows and macOS apps ...

But looking at the feature matrix for the full product it says:

> deploy to the platforms you need to support and with RAD Studio that includes Windows, macOS, iOS, Android and Linux!

https://www.embarcadero.com/products/delphi/product-editions

> Build Linux client / server applications (includes FMX GUI for Linux) The RAD Studio Linux Compiler enables compiling applications to popular Linux platforms. FireMonkey GUI for Linux extends the FireMonkey UI framework to provide full Linux GUI support.

Only offered on Enterprise ($4K) / Architect ($6K) editions.

> The free Delphi community edition

For a moment I was tempted to look into Delphi again, as I have spend many years in that environment. However, I see now its free until you hit USD 5.000 revenue per year. Not 0 USD, not USD 50.000, but only USD 5.000. Yes, that is the Embercadero that I knew. Probably this 'free' edition is canceled next year. Would not be the first time...

Edit: yes, still only runs on Windows

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... ).

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.