HACKER Q&A
📣 ajmurmann

Building a Desktop App in 2022


I am looking at building a relatively small desktop app. It would handle confident information that I don't want to have to handle for other people and storing it on the web might in fact deter some potential users. That's why I want to build it as a desktop app rather than a web app which would be where I have the stronger skill set.

The app should be lightweight, since it won't do that much (think fancy note taking for a few specific use cases), but ideally it also would be cross-platform. An Electron app would give me the cross-platform, but it's definitely not lightweight and might even feel sluggish. I know everyone here loves to hate Electron. Right now I am inclined to just write it in Swift and make it only support the Apple ecosystem where it also would fulfill all my personal needs, but miss out on lots of potential monetization (which realistically will never happen if I look at my past side projects). Another option would be Qt which I used to write 20 years ago, but it seems very expensive.

What other options would you look at for building a desktop app in 2022?


  👤 samwillis Accepted Answer ✓
Pick the platform that you know well and will get you a working app to customers as quickly as possible. If you have a web background that’s probably electron. Ignore the HN hive-mind gate keeping about Electron, it’s irrelevant. If it gets your idea out the door quickly it’s the one to use.

No one really cares if your app is an “inefficient” electron app of it solves their problem for them.

Electron may be arguably “heavy on memory” but it certainly isn’t sluggish, just look at VS Code (without poorly written plugins) or Slack, both are amazingly fast.

Also you mention it’s a “note taking” like app, if you need a rich text editor using a web browser based platform allows you to use all the incredible wysiwyg/rich text editor toolkits available.

There will always be the option to rewrite the app in a native platform later if you are successful.

Annother bonus with going the hybrid web/electron route is it very easy to extend to mobile later with something like Capacitor.


👤 b6fan
Lazarus / LCL. It is cross-platform, lightweight (more lightweight than Qt since it uses native widgets), can be used for commercial purpose, and is fast to compile.

The limitation is mainly that the widgets are limited. For example, comctl32.dll hasn't got new widgets since Windows xp. So depending on your needs, it might fit perfectly, or lack some features and that's going to be painful.

The Pascal language will feel outdated. But you don't have to do everything using it. You can, for example, write the non-UI logic in other languages and then glue them using dynamic libraries.


👤 terhechte
I recently finished a cross platform app written w/ Rust / egui: https://github.com/terhechte/postsack

Coming from Swift, it was actually a fun experience. It doesn’t look very native, but neither does electron..

Another nice Rust ui framework is Druid: https://github.com/linebender/druid


👤 detaro
> Another option would be Qt which I used to write 20 years ago, but it seems very expensive.

on desktop, using it under LGPL is not really an issue, so you don't have to go for commercial (where I'd agree the value proposition isn't there very often sadly)


👤 0xmarcin
Recently I have built a few JavaFX apps (e.g. https://github.com/marcin-chwedczuk/rfid).

Pros of JavaFX:

- Easy to start if you are familiar with Java and Maven/Gradle.

- Cross platform by default, I ran my apps on macOS, Linux and Linux on Raspberry PI without any problems (just remember to avoid AnchorLayout).

- Can generate deb packages for Linux and DMG for macOS.

- There is a TestFX project for writing GUI "clicky" tests, library seems to no longer be actively maintained but covers all common cases.

- SceneBuilder, ScenicView tools for rapid GUI development.

Now the cons:

- Java 9 module crap, JavaFX is modularized and mixing modular and non-modular libs (e.g. Guava) is real pain.

- Controls are quite primitive there is a TableView for displaying tabular data but there are no column filters out of the box. There are some projects that provide custom controls but there are quite poor compared to what you would get with C# and WPF/WinForms.

- Poor documentation for less common use-cases.

- A lot of bugs and missing features e.g. tray icon in macOS, there are workarounds that _sometimes_ work but can cause a lot of other troubles (e.g. calling AWT api before JavaFX starts).

To sum up, if you know Java and it's build tools and you app is simple then I recommend checking JavaFX out. If you need a more complex GUI then better keep out from it.


👤 gitgud
Some thoughts of mine:

1. Write it in the language and ecosystem that you're familiar with. Speed of iteration is more important than the tech stack or executable size...

2. Focus on delivering a working and useful application, performance and memory footprint might not even matter if no one uses the app...

3. Cross-platform has many drawbacks to consider, by taking on cross-platform you're taking on many OS specific bugs which slows down iteration speed...

4. (not mentioned but) Mobile apps should be an after thought, including iOS/Android in some cross-platform build makes things even more complex and slower...


👤 feoren
I know it's boring, but lately I always reach for WPF (Windows Presentation Foundation) in C# when building a desktop app. I know people hate XAML but I suspect they're trying to do way too much with it. Stick to basic controls, StackPanels and Grids for layout, have everything you possibly can bound to your ViewModels, lots of DataTemplates, and it's very nice.

Edit: It doesn't really seem to be all that great at cross-platform though, at least not without your clients jumping through hoops. So maybe it fails on that criterion.


👤 amerkhalid
It looks like there is some effort to port Swift to Windows: https://developer-tech.com/news/2020/sep/23/hey-swift-develo...

So you maybe able to write for MacOS for now and build Windows version later, if you validate demand and Swift support on Windows matures.


👤 tomjen3
Write it in Java. Use nothing but the libraries that comes with Java unless you absolutely have to. Use Swing for the layout.

It is not sexy, but without heavy libraries and enterprise patterns, Java programs are surprisingly small and pretty fast. Development is well supported in all IDEs, any question you could have has a stack overflow answer, and it is, of course, cross platform.

Alternatively download Lazarus and free pascal.


👤 nemwiz
I've recently shipped a desktop app for the first time in my career and it wasn't an easy experience.

I can echo what others have said - choose a technology that you are proficient with. In my case this was web so I went with Electron which was connecting to a small Python/Flask server running locally.

It worked great and I didn't had major issues with Electron, however my biggest hurdle and where I spent a lot of time (even more time than developing the app!) was publishing it on different stores like Microsoft store or Snapcraft for Linux. You haven't provided a lot of details about how you plan to distribute the app but do not underestimate this effort if you plan to use any of the stores.

Shipping for Snapcraft is very complex as you need to learn a lot of new stuff and in my experience their documentation was not great so there was a lot of trial and error, digging through forums and internet.

For distributing on Windows security plays an important role. Modern Windows is protected with Windows Defender and Smart screen etc. and it's impossible just to build an executable and send it to someone. You have to sign your app with a certificate (which is pricey ranging from 100-500$) a year or ship it through Microsoft Store for a small registration fee which takes time and you have to go through their process. There is a third option of sending your executable/installer to Microsoft so that it can be scanned for viruses etc. but it's cumbersome because it's manual.

I saw someone mentioned Tauri, it looks very promising but it wasn't mature enough for my use case. It might work for your scenario, do check it out.

In general, building and distributing desktop apps in 2022 is a real pain and I completely understand why everyone is moving to web nowadays. :)

Good luck and do reach out if you need any help.


👤 PragmaticPulp
Pick the platform you're most comfortable with and start writing.

It's more important that you get something to market as fast as possible, even if it's Apple-only.

You can always go cross-platform for a V2 release if it takes off. You can't, however, get back all the time you'll spend learning a new platform before you even get started.


👤 armchairhacker
i recommend Kotlin or Java, JVM and Gradle.

personally i find it very easy to make apps for the JVM in Kotlin. IntelliJ support for Java and Kotlin is the best IDE support for any language ever - creating a project, debugging, running tests, refactoring, etc. are seamless. Gradle packages are usually very good quality (although log4shell did originate there). The JVM is fast and reliable, and IME it’s much easier to track down exceptions than C-based apps or JavaScript. The JVM runs on macOS, Windows, Linux, and Android (though not iOS or web).

The main downsides of the JVM are that “native” or neat-looking UI is a lot harder than Electron, your apps will probably have the distinctive Swing style. Moreover, the JVM itself is not lightweight (I think it’s about 150MB), and you have to either include the JVM in your executable or download it on client machines.


👤 phendrenad2
First, try to do some market research. If you can bootstrap on one platform, you can afford to pay someone to rewrite it later. I'm guessing many potential customers don't have a computer either. Cross-platform is probably a good idea eventually. Including mobile. Since I'm guessing with a note-taking app for confidential information (medical?), your customers might be word-of-mouth. I'm guessing Windows is a good target, but you may want to think about mobile-first. If you go with Windows, Qt is a good choice. But give Electron a shot too, it's probably not that slow for a simple app. It's when people start piling heavy themes and bad algorithms on top of it that it gets slow.

👤 tonyedgecombe
>Right now I am inclined to just write it in Swift and make it only support the Apple ecosystem where it also would fulfill all my personal needs

I think your gut feeling is probably right. Unless there is a clear and obvious business requirement I would stick with one platform to start with.

All of the cross platform frameworks are compromised (and always will be). Targeting more platforms will be more work. The result won't be as nice.


👤 dusted
I'd say Java, except I don't like Java and getting native-looking UI seems to require rebuilding it for each platform, taking away it's one merit of "running the same jar everywhere".

Qt is relatively easy to cross-compile for at least linux and windows, and if you're mac-native, it might be easy to build for all three platforms


👤 tored
I recently started to code in PureBasic

https://www.purebasic.fr/

Works well for creating cross platform GUIs if you can accept the somewhat archaic BASIC dialect it uses.


👤 cercatrova
Flutter is cool, it has desktop support although it's still under development.

https://flutter.dev/multi-platform/desktop


👤 amosj
Flutter is excellent, not too heavy and has decent cross platform support

👤 pelagicAustral
There's Xojo, for small cross platform development on Macs... I've used it in the past for small desktop applications. Its commercial but I think they do have different license tiers.

👤 clownworldclown

👤 terrycody
You can code in Python and make it executable, I think someone posted this project recently?

👤 MarkMc
Consider using Java with the SWT library, which gives you native widgets