r/cpp • u/germandiago • Mar 19 '26
Modern declarative EDSL for graphic user interface in C++? Not QML or XAML.
Hello everyone,
I have been investigating lately (after using NiceGUI for a real project) and learning Jetpack Compose (not writing any real code with it, would do it with Jetpack Multiplatform if ever).
I am really impressed by Jetpack Compose approach, especially UDF.
I thought there could possibly not be a better way than MVVM tbh, after using it for years.
But after seeing how declarative composition inside the language, not with XAML or QML can be done, I am sold in the amount of boilerplate that can be saved, plus the better integration when the dsl is in the host language.
So I wanted to mention I found this, which I think could be a good start for some experiments, on top of wxWidgets: https://github.com/rmpowell77/wxUI
I think it has a talk in CppCon2025 here: https://www.youtube.com/watch?v=xu4pI72zlO4
Kudos to the author for bringing something like this to C++! Definitely useful.
I would like to hear your opinions on this style of EDSL GUI embedding and pros/cons you find for those of you who do GUI programming all the time.
Also, wild idea: with the power of compile-time C++ programming and C++26 reflection, it would be possible to get existing xaml interfaces and convert it into regular C++ at compile-time via #embed or #include and not even changing the EDSL itself and making it directly embedded and reusable in C++? That would be plenty useful.
View all comments
Show parent comment
4
u/Electronic_Tap_8052 Mar 19 '26
Yes and it looks like a nightmare for anything other than 'textbox with button' guis. I couldn't even comprehend what their basic example was trying to tell me, and I maintain guis for a living.
Because its standardized and the compiler and any IDE under the sun is going to understand it and be able to traverse it very easily, give you hints and summarize functions and so forth for you, and autocomplete will work well out of the box.
For every other language you have to download a linter plugin of varying quality and maintainedness, or otherwise just rawdog a text file which is endlessly frustrating. Plus I tend to forget the syntax of <insert 10th declarative markup language> and have to consult the documentation ad nauseum since autocomplete won't (in my extensive experience) work at all.
GUIs are inherently coupled, though, so you almost always have to end up searching for a field. Properties generally suck as they are type erased, and depending on the language, that demotes compile time errors to runtime errors. Simple references solve a lot of this needless complexity.
Then how do you search for them dynamically? Like I said, this is all well and good for very, very simple use cases. But the minute you have even a slightly complicated gui - which, in my experience, is almost all of them - you end up with either a tangle of signals and slots, or a bunch of find("widgetname") calls. Frankly I prefer to just save references to my widgets in the header file and refer to them elsewhere that way. At least Qt lets you compile your ui files into headers that the IDE can understand.
I'm sure this stuff works fine for a lot of people's use cases, I guess that's why its so popular, but I maintain several advanced guis for a machine with a lot of complex networking and distributed systems, and I dread touching the stuff that isn't just plain old c++ - the QT qml and ui files, in my case. I've also used Kivvy extensively and that was somehow even worse than qt.