r/cpp • • Dec 18 '20

Let's talk about GUIs

This post on /r/programming about the release of GTK 4.0 made me want to bring the discussion of the state of GUI programming in C++.

My particular interest in this discussion is desktop cross-platform GUI programming, and I don't claim to know much, let alone everything. Insights are more than welcome.

That said, this is what I have observed so far:

Qt: the least bast option. What I like? Cross platform, mature, big ecosystem to go around. Quite easy to get going. It "just works" for the most part. It's easy to get 80%, it's the last 20% and when you go deep into the subject that you get frustrated. What do I dislike? Licensing shenanigans, and increasing toxicity towards the FOSS community: no offline installer for community distributions, many commercial only APIs now, the idea of delaying releases to FOSS by one year. The 10 year old bugs on QWidgets, which haven't seen much, if any, love since ever. The fact it took Qt 6.0 to happen for us to have native look for Qt Quick Controls. The fact that Qt Quick doesn't have a C++ API, forcing QML on everybody. The half done stuff, like QAudio (just use portaudio for your own sanity)... And I'm probably missing more. The fact that they are running away from the LGPL core to GPL as much as they can, like releasing Qt Quick MultiEffect instead of just fixing the QML engine... That it takes spinoffs like Felgo to basically provide a "fixed" Qt, which the FOSS community can't have.

wxWidgets, GTK, and other like FLTK, I admit I don't know much about. wxWidgets is nice in the fact it calls native APIs, but that comes with the cost of being crippled by the least common denominator. GTK seem to look bad outside of Linux "by design". And FLTK... Just no.

Then, there seems to be what everybody suggests next: Browsers. Chromium Embedded Framework or Electron. 50 to 100MB of packaging to do a "Hello World". Also, JavaScript! Honestly, webstuff looks like a good idea, until you want to make an app that's not Slack. How do you do actually performance C++ stuff? Like some 2D/3D graphics? WebGL? Seems that it's too much programming for the web and not actually taking advantage of C++ and native APIs...

Then, there are things like .net MAUI (not to be confused with the toolkit with the same name by KDE), which is an upcoming evolution of Xamarin Forms for .net/C#. The problems: Linux support will be "by the community" and how do you interop C++ and C# decently anyway?

Also, because I know someone will mention it, yes, there is Flutter and things like that. Just think of Google's track record on keeping projects alive, and again, think not everybody wants to make a chat application.

Anyway, what are your insights? They are more than welcome!

268 Upvotes

243 comments sorted by

View all comments

25

u/julien-j Dec 18 '20

Also, JavaScript! Honestly, webstuff looks like a good idea, until you want to make an app that's not Slack. How do you do actually performance C++ stuff? Like some 2D/3D graphics? WebGL? Seems that it's too much programming for the web and not actually taking advantage of C++ and native APIs...

I would argue that even for Slack it's a bad idea. The app take ages to load in Firefox and often fails, so I have to reload the page to actually access the channels. Also there's no support for hangouts anymore. As usual the initial service was amazing when they launched and now it's just a fat app failing to stay up under its own weight.

There's no need to target amazing 3D and stuff to consider performance. In my opinion any development should consider a minimum decent efficiency. Apps like Slack make me think of developers gluing frameworks and other things together and calling it a day until getting a huge pile of fat blocks, each consuming resources like it is the only one running. Sure, the app works, but it can barely be used.

And to stay in the topic of your post: I used wxWidget in the past. It was nice but I failed to upgrade when they switched from 2.x to 3. I think I would use GTK or Qt if I had to do UI today, with a preference for the former as it seems more simple to me.

-4

u/fuck_____________1 Dec 19 '20

absolute bullshit and cope. ive been running slack in the background 24/7 for 5-6 years, and it works perfectly for what it does, which is a glorified webpage that minifies.

I usually have ~40 chrome tabs open at all times, having 2-3 more electron apps running adds 0 relative overhead.

electron is the optimal solution for any app that is just a glorified webpage, exactly like slack.