Ask HN: How to make a native GUI with a modern language?
87 points| throwaddzuzxd | 3 years ago
- I want to make a native looking GUI
- Cross platform (macOS, Windows, Linux)
- With a sane language (no C, C++ or Objective C)
- Ideally with a data flow looking like unidirectional data flow / Elm architecture
What options do I have?
ceronman|3 years ago
Most cross platform frameworks won't really look 100% native. The only exception I know is wxWidgets, which provides an abstraction layer over the native toolkits. It's written in C++ but there are bindings for Python, Ruby and other languages. But even using this, apps might not feel truly native. There is more to nativeness than looks. It's also about subtle conventions and ways to do things. You only achieve this when you use a native framework and pay a lot of attention to the HIG guidelines of the OS.
My personal (and perhaps a bit unpopular) opinion is that native looking is a bit overrated. And it's mostly macOS users who look for this. Linux and Windows users already get a lot of diversity in their looks and feel because there is no single framework for those OSes.
More important than native looking is to have a GUI that is fast, efficient and accesible. The best option that provides this in a cross platform way is QT. Java Swing and JavaFX are also good options.
The most productive tool to have cross platform GUIs right now is Electron. That's just a fact. And it's the reason why so many modern products are using it. But as we all know, there is a price in efficiency.
There are a bunch of new projects in the works to improve cross platform GUI for modern languages. JetPack Compose Desktop, Flutter, Slint and many more. But these are not yet fully mature.
bpye|3 years ago
I would echo this. Consider applications like Photoshop or Blender, these don't really have a 'native' feel anywhere but their UX is generally responsive. On the other hand you have Electron applications that don't feel native and are also sluggish...
marwis|3 years ago
register|3 years ago
mattgreenrocks|3 years ago
Beware the bias of the loud minority. For every 1 noisy user, there may be 50 quiet users who are fine with the decision to use Electron.
Shipping beats not shipping every time, and if Electron is what you need, then do it. I say this as someone who does not like Electron, but also as someone who knows that writing comments on HN is 100x easier than actually shipping production software.
Gentil|3 years ago
I have 16GB RAM and even then I feel the hog with Discord, Slack, VS Code, A note app taking up too much memory. Then there is unnecessary security risk of bringing all the browser issues along with it.
People shouldn't have to buy an expensive Mac books to use normal apps. That should be for MLOPS or other processing heavy tasks.
Also, an Electron app uses anywhere around 150+MB to 400ishMB ram on normal cases. For one app.An app like QOwnNotes uses only a small portion of it. 50MB-100MB max. So when you you add just 10 electron apps, the number just blows up.
I feel like whatever progress with performance we are making with processor is just cancelled out with things like Electron. That is just sad.
So no. I don't think this is a good example of loud minority scenario.
dspillett|3 years ago
Beware the bias of the loud minority.
Hear hear.
Though depending on the application(s) in question, if JS and things that traspile to it are attractive to the developer then they could also consider an offline-first/-only web app. Not practical for everything and adds its own family of potential complications, but worth considering.
> but also as someone who knows that writing comments on HN is 100x easier than actually shipping
As someone who has a huge pile of projects just waiting to be started (and one or two languishing in a PoC state) I think your 100x factor is more than a little too small!
thrwawy74|3 years ago
garblegarble|3 years ago
I spent a few hours last night on a personal project trying to get something relatively simple working as a SwiftUI macOS app. I needed to customise a bunch of components to get it close to what I wanted.
I decided to give Electron a go, and had what I wanted up and running quite literally in 5 minutes, and it starts and is responsive within 500ms. It's taken longer to figure out how to ship it as a .app package than to write the code. That's nothing short of amazing.
lvass|3 years ago
bool3max|3 years ago
socialdemocrat|3 years ago
It does make GUI which are native to the platform but you get a small native binary which renders OpenGL.
Is Making Advanced GUI Applications with Godot the Future? https://medium.com/swlh/what-makes-godot-engine-great-for-ad...
d--b|3 years ago
withinboredom|3 years ago
ghishadow|3 years ago
socialdemocrat|3 years ago
Here is a simple Julia GTK project on GitHub: https://github.com/ordovician/RocketBuilder.jl
Some articles I wrote related to GTK programming with Julia and GTK in general:
- Understanding GTK Layouts: https://itnext.io/understanding-gtk-layouts-13e5a36256fa
- Hiccups Writing GTK3 GUI Code in Julia: https://towardsdev.com/hiccups-writing-gtk3-gui-code-in-juli...
If Julia is not your cup of tea then GTK can be used with Go and Swift as well.
alhirzel|3 years ago
Dracophoenix|3 years ago
tomcam|3 years ago
sethjr5rtfgh|3 years ago
[deleted]
okso|3 years ago
While the Qt API is imperative (`self.layout.addWidget(self.text)`, ...), focusing on declative Qml whenever possible helps with a more declarative approach.
lbriner|3 years ago
Why? The only way to get a truly native look and the ability to specialise for each OS. Maybe Windows does threading better than Linux and can be optimised in some way. Maybe Linux has some nicer native UI controls that could make that part better on Linux.
Otherwise cross-platform mostly means a UI that is not native looking on any platform. Haven't used QT recently but of all I used, that was the closest to what you are asking for (I was using C++ - sorry, it's not that bad!) but I think there are bindings in other languages, although they might well have some bugs compared to the basic C++ version.
apitman|3 years ago
ziftface|3 years ago
PaulHoule|3 years ago
I made something pretty complicated with tkinter and Python. It's not that hard to do but the result looks awful, it doesn't support many features people expect in 2022, and the documentation for using tk in Python is poor. You probably need to refer to the tcl/tk documentation and translate it in your head to apply to Python.
As much as people hate Electron, the rendering engine in a web browser is head and shoulders better than any other cross-platform system and I think it's a sane model for programming. The main trouble w/ Electron is that you have 30MB of runtime for any application, even if it something that could be coded in a 25k .EXE file based on Win32.
invalidname|3 years ago
But the problem is the deployment story. It requires native libraries so you need to package it somehow. Ideally, one day GraalVM will support JavaFX. That day isn't here. So you need JavaPackager which is one of the more awful ways to deploy anything at scale.
It pains me to say it as a Java fan, but most people will be better off with Electron.
thiht|3 years ago
It really felt like something created by someone but never used in the real world. Is it even used anywhere?
codeptualize|3 years ago
It uses the OS's browser so it doesn't have the bundle size issue you describe.
TrianguloY|3 years ago
shrubble|3 years ago
I recently found this tutorial: https://tkdocs.com/tutorial/index.html and am going thru ut.
rr808|3 years ago
JavaFX has the same problem? Or you rely on user's JREs already installed? I'd think 30MB really isn't much any more.
awinter-py|3 years ago
cosmotic|3 years ago
Apreche|3 years ago
Now you can build completely native GUIs in the appropriate language for each platform. Start with the platform which will likely have the most users for the application. Bonus if the application is open source, other developers will build all kinds of native GUIs for you. Just look at how many GUIs are out there for things like PostgreSQL, Git, IRC, etc.
I know this doesn't exactly meet your requirements, but I think this is the way to go if starting something in August 2022.
crabbygrabby|3 years ago
kweingar|3 years ago
immigrantheart|3 years ago
desireco42|3 years ago
I was considering using it for some app that otherwise would be PWA. While I didn't use in-depth features and didn't run into any serious problems, it is likely that not everything will be perfect, but it is also likely that overall experience will be more pleasant.
https://tauri.app/
Check it out.
threesmegiste|3 years ago
bodge5000|3 years ago
Though overall, its not an uncommon issue. I've found myself in the same place multiple times, I've even considered using a lightweight game engine just for their UI features. But next time I run into it, I imagine Flutter will be what I go with
Edit: Just realising you said "native-looking". Not so sure about Flutter for that, I'm not sure such a thing exists.
Morthor|3 years ago
snehesht|3 years ago
1. https://github.com/tauri-apps/tauri 2. https://github.com/zserge/lorca 3. https://github.com/webview/webview
neverartful|3 years ago
There are some very powerful capabilities in Objective C (like swizzling) that can be of tremendous help when you have some oddball functionality to implement. This would be conceptually very similar to the monkey-patching that folks do with Python. Perhaps this is the sort of thing that makes it not sane to you?
WorldMaker|3 years ago
- Native looking: MAUI supports native controls as much as possible
- Cross platform: Nearly everything but Linux today (and there are forks out there trying to bridge that gap); macOS (Catalyst), Windows, iOS, and Android
- C# as the default .NET option is a very sane language. Other options may be possible with more effort. (Some people are still working on that.)
- MAUI's focus is still on declarative XAML UI with databinding (MVVM), but there's a growing community for MVU (vaguely Elm-like) architecture including some official out-of-the-box support now.
zerr|3 years ago
taumoeba|3 years ago
After finishing, I regret spending so much time on it. For my use case, I think it would have been a better use of time to just use Electron. At least until .NET MAUI has Linux support, which is looking very promising.
[1] I haven't tried MacOS because I don't have a Mac and I believe it has OpenGL compatibility problems. It works great on Windows and Linux though.
rish|3 years ago
gjvc|3 years ago
samorozco|3 years ago
Also java can run on any platform so javafx, etc..
prewett|3 years ago
- Qt: the most widely used, but is a little janky on macOS and they've been going down the JS route recently
- wxWidgets: is a possibility, I haven't used it in a long time.
- GTK: "native" for Linux, but technically cross-platform. However the experience is lousy (and it is C, not even C++)
- JUCE: another long-standing, somewhat niche toolkit, but I've never used it or anything written in it.
- Flutter: must use Dart as the language, as far as I'm aware. Also, not sure how native-looking it is.
There are also Java and C#, but I've never used a Java UI that looked or felt remotely native (or even "good" for that matter). Haven't used any C# apps but I assume some toolkits exist.
gengiskush|3 years ago
throwawaymaths|3 years ago
thiht|3 years ago
yogthos|3 years ago
mikewarot|3 years ago
I happen to think Lazarus (based on Free Pascal) is great, but it's not a functional language at all.
gorjusborg|3 years ago
thiht|3 years ago
epirogov|3 years ago
https://github.com/fyne-io/fyne
I done research and have found golang fune is able to run even on thin devices. It core depend on open gl and can be changed to run with messa for embeeded device displays. https://pirogove.blogspot.com/
dexterlagan|3 years ago
In the free world, I'd say Racket is the next best thing. Native UI, runs on anything. But you have to fall in love with Scheme. It's easy for me, I'm already sold.
I haven't found anything else that a) doesn't break in production, or 2) turns out to be a giant pain in the.
Gentil|3 years ago
Ancapistani|3 years ago
I've looked at Kivy in the past, but it didn't seem mature enough to rely on, especially for deploying to iOS/iPadOS. I just spent a couple of hours going through their documentation, building their example "Pong" app, and deploying it to macOS, iPadOS, and Android. All went off without a hitch, though I didn't mess with signing or trying to release them to the various app stores.
I'm going to say Kivy is more than capable of the things I'd want it to do. Looks like the roguelike I've had in my head may make it onto the screen in the near future!
segphault|3 years ago
poulsbohemian|3 years ago
You've shared technical requirements, but you haven't shared business requirements. You should ask yourself whether you can actually achieve your business / user ends with a cross-platform approach. The three platforms are unique and users across the three have different expectations. For example as a Mac user, unless the software is super specialized such that there isn't any competition, a native Mac-focused solution will always be preferable to something that "kinda sorta" looks and acts like Mac software.
Without knowing the purpose of the software you are building, one has to really wonder if it needs to be native or should rather be a web app (for example), or even mobile first or tablet preferred.
Just some thoughts.
ydnaclementine|3 years ago
andrewmcwatters|3 years ago
If you don't actually care about creating platform native UIs, you'll always be creating something that is a second-class design while putting in first-class effort. Why?
Frankly, you're better off just learning the operating system platform native UI programming language and get over yourself if you want to create something that looks like it was actually designed for the OS you're using.
And really, it's immature and insulting to call languages insane. Suck it up, these are peoples' professions here. No one wants to read that.
taffit|3 years ago
[1] https://vlang.io/
lobo_tuerto|3 years ago
tored|3 years ago
Personally I searched for many years for the perfect GUI system, the unicorn, but never found any. By doing a stricter prioritization I came to the conclusion that writing in a modern language is overrated.
pipeline_peak|3 years ago
Maybe look into Skia, it’s Googles abstraction layer for multiple graphics libraries on multiple platforms.
But if you are just learning, I wouldn’t concern yourself with any of those sort of environment conditions, just figure out how to make something that works on your preferred OS.
For example, if you use Windows, learn 2d rendering with direct x. Learn about event handlers for controller interaction. And of course read about MVC.
4silvertooth|3 years ago
https://gitlab.com/sciter-engine/sciter-js-sdk
*Edit Also checkout https://haxe.org/
tough|3 years ago
pull_my_finger|3 years ago
oumua_don17|3 years ago
[1] https://news.ycombinator.com/item?id=13952643
[2] https://news.ycombinator.com/item?id=29181404
rschachte|3 years ago
86J8oyZv|3 years ago
1ark|3 years ago
Cross platform GUI toolkit is a very underdeveloped area.
moasda|3 years ago
https://www.lazarus-ide.org/
cmacleod4|3 years ago
cmacleod4|3 years ago
Also "modern" is in the eye of the beholder. There are many features that Tcl had long before some of the supposedly more modern languages. In some areas like single-file deployment of applications it's arguably still ahead of its newer competitors.
jf|3 years ago
unknown|3 years ago
[deleted]
Crungus|3 years ago
jimbob45|3 years ago
WorldMaker|3 years ago
ElemenoPicuares|3 years ago
hnthrowaway0315|3 years ago
waspight|3 years ago
aalhafoudh|3 years ago
samarthr1|3 years ago
1. Take care to ensure that you follow platform guidelines
2. Ensure that the view and controller are not tightly coupled
3. Ensure that whatever libraries you want to use have support for all platforms you want to support
4. Pray that you don't need something very platform specific (or need to use Bluetooth, which I am told is a huge pain)
rvz|3 years ago
Flutter Desktop seems promising, and at least good enough to create some cross-platform Desktop apps like Rows: [0]
[0] https://blog.rows.com/p/we-built-a-desktop-app
kimsabiz|3 years ago
[deleted]