There's a lot of overstated FUD about the moc. It's a preprocessor that expands a few macro strings into relatively simple boilerplate C++. Yes, it's a separate little preprocessor binary instead of using C++'s built-in macro system, but the concept itself is not foreign to C++.
The macro incantations aren't massively complicated and mostly are simple labels placed in header files; body code rarely uses anything moc-related these days.
Compared to the crazy stuff Microsoft has done over the years within and on top of C++ on their platform, Qt's moc is barely a footnote.
I respect not liking it, and I totally get the appeal of doing the same thing with tools built directly into the language (which to this day aren't fully comparable, and are mostly recent - check into the verdigris project for a solid and interesting take on attempting this), but it's a reasonably straight-forward approach to the problems it solves.
> Yes, it's a separate little preprocessor binary instead of using C++'s built-in macro system, but the concept itself is not foreign to C++.
It does have it's drawbacks. The MOC heavily penalizes build times, and build caching tools like ccache don't work out of the box with it. So not only does the MOC worsens builds, it also prevents basic optimizations from mitigating it.
> Compared to the crazy stuff Microsoft has done over the years (...)
Microsoft did a fantastic job with it's GUI frameworks. WPF is a stellar example of getting most things right. It's astounding how views are so trivial with WPF. XAML voodoo has it's critics but no one praising Qt would ever dare point a finger at XAML.
> It does have it's drawbacks. The MOC heavily penalizes build times, and build caching tools like ccache don't work out of the box with it. So not only does the MOC worsens builds, it also prevents basic optimizations from mitigating it.
You have to compare those drawbacks directly to the alternatives, though. I don't have numbers to cite, but I think the attempts at replacing the moc with newer C++ lang features also usually didn't exactly hit the compiler fast paths.
Yes, perhaps optimizing the compilers would be nicer.
> You have to compare those drawbacks to the alternatives, though. I don't have numbers to cite, but I think the attempts at replacing the moc with newer C++ lang features also usually didn't exactly hit the compiler fast paths.
Maybe so, but this is not what my comment is about. What I'm saying is that MS has made much more invasive changes to C++ as a language than Qt has in its platforms or frameworks, e.g. compiler-backed extended and different behavior. Or look at C++/CX (since phased out, thankfully).
There's a lot of "If you're using Qt you're not using C++!!1" FUD to confuse newbies, while it's much easier to inadvertently write non-portable C++ with many other frameworks. Yes, it's a whatboutism (which I hope to have compensated for with many other detailed comments in the thread), but this double standard tends to irk me.
> You have to compare those drawbacks directly to the alternatives, though.
It's ok to claim that Qt's MOC optimizes for developer experience,and all other tradeoffs are acceptable.
> I don't have numbers to cite, but I think the attempts at replacing the moc with newer C++ lang features also usually didn't exactly hit the compiler fast paths.
This doesn't really matter. It's not just the MOC. Using Qt UI form files forces UIC into the picture, which also fails to be cached.
> Yes, perhaps optimizing the compilers would be nicer.
The compiler is not the problem. Obviously. WPF also uses code generators and it's not plagued with long build times.
> Maybe so, but this is not what my comment is about. What I'm saying is that MS has made much more invasive changes to C++ as a language than Qt has in its platforms or frameworks, e.g. compiler-backed extended and different behavior. Or look at C++/CX (since phased out, thankfully).
This reads like whataboutism, and fails to address Qt's problems.
> There's a lot of "If you're using Qt you're not using C++!!1" FUD to confuse newbies
I never saw that once, not do I understand why that is relevant.
moc is the part of C++ the standards folks didn't see a need to integrate, but it should have always been there. Since all it does is take syntactic sugar and output more C++, it's clearly C++.
of course, C++ eventually gained the ability to implement moc natively using a more general solution.
to me, moc and the Qt base classes sort of round out C++ to me in a way that is better than the alternatives. I can imagine an entire world of application development based on Qt C++ base, and in fact I've written a few network servers this way. Simply having event loops with message passing built-in makes programming that much more enjoyable for me.
The macro incantations aren't massively complicated and mostly are simple labels placed in header files; body code rarely uses anything moc-related these days.
Compared to the crazy stuff Microsoft has done over the years within and on top of C++ on their platform, Qt's moc is barely a footnote.
I respect not liking it, and I totally get the appeal of doing the same thing with tools built directly into the language (which to this day aren't fully comparable, and are mostly recent - check into the verdigris project for a solid and interesting take on attempting this), but it's a reasonably straight-forward approach to the problems it solves.