Ask HN: What should I use to write native desktop apps for Ubuntu?
I am computer science student. And I want to write a native desktop app for Ubuntu which will be displayed in the system tray. I tried building a sample app using ElectronJS but it compiles to very big file size for a hello world system tray app.
I have looked into GTK and Qt but I am confused which one I should use. I want to know which one will be easier to pick up and get going.
45 comments
[ 3.8 ms ] story [ 108 ms ] threadQt Quick / Kirigami is a good option for that type of application though.
KDE also provide a nice configuration tool for gtk apps.
Worst case, I feel gtk apps look and feel as they do in gnome, which is okay. The gnome crowd paid attention to the look and feel of their software and this is noticeable.
I still do prefer KDE apps most of the time, I always feel they behave the right way. What should be zoomable with the mouse wheel is for instance.
Qt apps also look good on gnome, especially when using the breeze theme. Gnome with this theme is beautiful.
However, many KDE apps are broken or ugly if QT_QPA_PLATFORMTHEME is not set to "kde" (and then you get whatever theme is configured in plasma, not the theme of your current desktop environment). At least outside of gnome.
Bare Qt apps don't have this problem: VLC looks good everywhere.
However, configuring the look and feel of Qt 5 apps is a pain outside of KDE.
Gtk3 apps are also more likely to behave better on a touchscreen (scrolling, for instance). Plasma do behave very well on a touchscreen. KDE apps, not so particularly well. Gtk 2 is a disaster, popup menus are unusable. This makes xfce unusable on touchscreens on which I tested it.
Some details, some behaviors are different between the toolkits. Overflowing toolbars unhide differently for instance (this is visible with LibreOffice vs LyX. I find Qt a bit annoying with this).
With Qt you get the opportunity to have a good opening file dialog. The gtk one is nice looking but quite annoying. It autocompletes in a surprising way (in KDE at least), and reauires typing Ctrl+L to type a path but the recently used files gets in the way (although is occasionally very helpful).
I also have observed that Qt apps play well with the DPI / font scaling setting of the xsdl x server on Android. Gtk apps require to set GDK_DPI_SCALE manually.
For programming, I would not hesitate between Qt and gtk. The Qt API is clean and straightforward and powerful. Gtk looks worse to me. And for the documentation, Qt is top notch. I might have missed something on the side of gtk. I would use gtk only if I have to use C.
Qt apps will also probably look better outside of Linux/BSD than gtk apps.
Gtk will probably look more native than anything on the Ubuntu desktop, since everything in Ubuntu is written in gtk. I would still consider Qt though. With care given to integration, good result should be reachable.
Edit: it was the first result on Google; https://github.com/getlantern/systray
Well... I wouldn't go that far, but over the years we've all managed to work around the warts of HTML/CSS and can put up with it.
(Amazon Facebook Google Apple Microsoft)
Doing things well requires expertise.
> Windows/Linux/Mac cross-platform apps were in the same place before Electron.
Seriously?! Qt predates Electron and is a far superior solution. Of course, if you only know web development, your existing knowledge doesn't translate over easily, but the reverse is equally true.
> but ask anyone today what they'd prefer to build an interface with and it's most like HTML/CSS
Only if they are already experienced in web development. Otherwise, Qt Quick is much better, taking the positives from CSS, without the downsides of using a document format to layout a UI.
> Especially for highly graphic intensive, responsive layouts, there's almost no competition really.
Seriously, Qt Quick is far better. Though on the desktop, you'd be better off not building a "highly graphic intensive, responsive layout" and instead adhering to the established norms.
Rather, HTML/CSS/JS is what you're stuck with if you're treating the web as your platform, which is tempting when your code is really just a front-end for a remotely hosted system anyway.
Electron is the result of people trained in web development turning their hands to desktop development, but not wanting to learn something completely new.
"Learning something new" has a massive cost when you apply that to an entire engineering team. A tool that can leverage existing resources to make people proficient in a new area simply through new technology would be a huge value added IMO.
Electron is a little like auto-translating your UI. It's easier for the developer and the user pays the price.
You can use GTK on other platforms too, I just never have.
Ultimately, what's important is to start making something. Any language, any toolkit, doesn't really matter all that much. If you don't like it, try another language, another toolkit.
I might try out relm + rust, to see what the state of the art is: http://relm.ml/relm-intro
I've used https://www.mono-project.com/docs/gui/gtksharp/ in the past, and it was easy. Looks like there is a notification area example: http://www.mono-project.com/docs/gui/gtksharp/widgets/notifi...
Looks like it's possible in go: https://github.com/mattn/go-gtk
And python: https://python-gtk-3-tutorial.readthedocs.io/en/latest/
It doesn't look very supported, but even node has GTK bindings: https://github.com/WebReflection/node-gtk
Honestly, thanks for bringing this up. Looking at these is interesting an nostalgic. It seems like everyone nowadays just does webapps, and its interesting to see "the state of the desktop in 2018".
https://www.lazarus-ide.org/ http://wiki.freepascal.org/Lazarus_Application_Gallery
If it's a quick thing then maybe just make it a shell extension.
The story of computer programming is the story of programmers avoiding the need to write native code. Assemblers, compilers, Cobol, C, C++, Java, Go all exist because hardware is the worst abstraction most of the time. Particularly because it is sticky. Twenty-five years after first programming on TRS-80's and Apple II's, I freaked out about allocating a 10,000 element integer array on a machine with 4GB of RAM and dual quad-core Xeons.
That's not to say that writing code at a low level might not be a good learning exercise. But it's not a reason to claim moral/ethical superiority. Engineering is about making meaningful tradeoffs based on project criteria. Resource allocation ought to be evaluated based on the importance of the problem the software solves...and consuming "too much" resources is often a reflection of the problem's importance. and problem importance can be a useful way of evaluating software quality.
Don't fight the last war.
Good luck.
[1]: And there was Java in the browser!
Does this statement hold true nowadays?
[1]: Fine for ACAD r11 because it was written in C or lower. Back then it really mattered, but it was also $2000 for the big box of floppies.
[2]: 1GB -- more than two orders of magnitude more ram.
[1] Java binding is officially supported: https://www.gtk.org/language-bindings.php