7 ms·
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.
- xor_null 8y agoAs far as i know ubuntu uses Gnome which means you should use GTK to let your app look nativ. I dont know how it will look if you use Qt.
- beojan 8y agoQGtkStyle and the Gnome platform theme mean this isn't really an issue.
- kitsunesoba 8y agoI just wish Qt supported headerbars... it’s really the only thing that GTK has that Qt doesn’t, and they complement many app designs very nicely.
- beojan 8y agoThey work for a very specific (i.e. consumption focused) type of application, but the implementation in GTK is pretty fragile. Qt Quick / Kirigami is a good option for that type of application though.
- kelnos 8y agoIn practice, though, I can nearly always tell when a new app I install uses Qt. It always seems a little off, and some little details end up not feeling right. If you use GNOME or Xfce and are starting a GUI project, it's better to just stick with GTK.
- beojan 8y agoUnfortunately, GTK applications in a Qt desktop are a complete disaster. This means if you use Qt, it looks and works well on some desktops and OK on others, while GTK is good on the latter and bad on the former.
- jraph 8y agoI have to disagree. I use plasma as my desktop environnement and I occasionally use some gtk3 apps like evince. The KDE team did a good job porting the breeze theme to gtk, evince is beautiful here. So is gedit and meld is okay too. The gtk header bar also looks good and I actually like it. Chrome also looks good here. 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.
- tenryuu 8y agoI'm writing a systray application in golang currently. Binaries turn around 3mb. There's an external library for cross platform tray support somewhere on github, I can't remember exactly what it's called though Edit: it was the first result on Google; https://github.com/getlantern/systray https://github.com/getlantern/systray
- kim0 8y agoWish Go had a more complete UI lib. Libui sounds promising though.
- openIce 8y agoWhy not simply use Java or C#? No one writes desktop software in JS
- atlasM 8y agoDoesn’t everyone write desktop software in JS now? Discord, VSCode, Skype, etc all use Electron
- endless1234 8y agoYou may not like them, but saying no one writes Electron apps is a bit disingenuous, no?
- beojan 8y agoFar too many people write desktop software in JS. I wish they wouldn't, but they do.
- aphextron 8y agoIt's not so much the greatness of JS that attracts people, but having access to the DOM and browser based rendering. HTML/CSS is the very best possible declarative syntax for building interfaces ever devised really. The alternatives are way less flexible and cross platform.
- drcode 8y ago> HTML/CSS is the very best possible declarative syntax for building interfaces ever devised really. 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.
- aphextron 8y agoMy argument basically comes down to the alternatives. Have you tried them? Native iOS development was a nightmare without deep mobile expertise until React Native and the like came about. Windows/Linux/Mac cross-platform apps were in the same place before Electron. IT's far from perfect, but ask anyone today what they'd prefer to build an interface with and it's most like HTML/CSS. Especially for highly graphic intensive, responsive layouts, there's almost no competition really.
- beojan 8y agoWhat languages do you know? With Qt, Python is an option but you're better off using C++. Bindings to other languages exist, of varying quality.
- jason_slack 8y agoI'm working on an app now and I using QT. I have used QT off and on over the years from 3.x days even. I still use QT because I feel if I wanted my app to run on other platforms like macOS or Windows I might have an easier time at least with the GUI piece. You can use GTK on other platforms too, I just never have.
- earenndil 8y agoThey will both probably be about the same, tbh. People seem to like Qt a bit more, but high-quality bindings really only exist for c++ or python. GTK, on the other hand, has bindings for most langauges. You could also use tcl with tk, java (or clojure or kotlin or scala or...) with javafx or swing, d with dlangui... 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.
- voodootrucker 8y agoThe safest, simplest option would be C, CLion and GTK. Qt is pretty heavy in it's own ways (though not as much as electron). I might try out relm + rust, to see what the state of the art is: http://relm.ml/relm-intro http://relm.ml/relm-intro I've used https://www.mono-project.com/docs/gui/gtksharp/ 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/notification-icon/ http://www.mono-project.com/docs/gui/gtksharp/widgets/notifi... Looks like it's possible in go: https://github.com/mattn/go-gtk https://github.com/mattn/go-gtk And python: https://python-gtk-3-tutorial.readthedocs.io/en/latest/ 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 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".
- Hydraulix989 8y agolibui showed up recently on HN, I also recommend wxWidgets.
- squarefoot 8y agoTake a look at Lazarus. It runs natively and outputs native binaries from x86 PCs to ARM *PI like boards. https://www.lazarus-ide.org/ https://www.lazarus-ide.org/ http://wiki.freepascal.org/Lazarus_Application_Gallery http://wiki.freepascal.org/Lazarus_Application_Gallery
- nartz 8y agoHow about javafx?
- iamcreasy 8y agoNot sure why you were down-voted. It's a valid option IMO.
- kevinsimper 8y agoI tried writing a GUI app in wxpython and it was pretty straightforward, however you need to figure out how to split up work task from the main rendering process if you go that way!
- whoaminow 8y agoGnome has won the war, it's the default for the major distro's so Gtk. If it's a quick thing then maybe just make it a shell extension.
- brudgers 8y agoPeople are down on Electron. But to me, it looks more like the future than GTK or QT for many things. In the end, Electron's tradeoff of resource use for ease of development is likely to win because computer capability will always trend above the line needed to run current web browser technology and Ubuntu ships with a browser. OK, Electron is not native. Neither is Java and every argument against Electron was made against Java twenty years ago and performance of Java apps on ordinary computers was often much much worse than Electron on its worst day.[1] 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!
- dikaio 8y agoZag -(- z. QQQ2:22$’ sqamth morning wass3! Ew::.:///:::////:::////:&@,. Awaasqqqz a :saw /- SaaS -,/: : . . As .a 🇦🇩🇦🇩🇦🇿🇦🇼🇦🇼🇦🇼🇦🇱🇦🇱🇦🇼🇦🇱🇦🇱🇦🇩. Zz. Z. Z Zz zZsz. Sasasasasaz-;3’em
- iamcreasy 8y ago> performance of Java apps on ordinary computers was often much much worse than Electron on its worst day Does this statement hold true nowadays?
- brudgers 8y agoNo. Partly because Java has become more efficient. Mostly because of Moore's law and similar increases in computing power. In 1995, the year Java came out, I bought a relatively powerful [1] but not top end computer: 486DX2 66mhz, 8MB RAM, 340MB HDD. It was almost ten years before I had a computer with enough RAM [2] to make Java applications merely something I tried to avoid all things being equal rather than clearly painful. [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.
- iamcreasy 8y agoIf I had to do it, I would use a language that I am comfortable with and the most used GUI library/framework in that language. I know Java well, so I'd either chose Java/Swing or Java/GTK[1]. [1] Java binding is officially supported: https://www.gtk.org/language-bindings.php https://www.gtk.org/language-bindings.php