←back to thread

196 points svlasov | 9 comments | | HN request time: 0.993s | source | bottom
1. kstrauser ◴[] No.40852102[source]
I haven't touched C++ since undergrad. Neither have I written any Qt code. But from memory, doesn't Qt's moc implement some of this stuff because it wasn't available in C++? Could this replace moc?
replies(4): >>40852283 #>>40852302 #>>40852535 #>>40854005 #
2. fluoridation ◴[] No.40852283[source]
Qt has straight-up dynamic reflection. You can get pointers to functions from strings, and such. This is just static reflections (which is still very useful!), so it's not a complete replacement. Even if it was, I would Qt would replace its build system.
replies(1): >>40855502 #
3. shkurski_ ◴[] No.40852302[source]
moc can be replaced without reflection: https://woboq.com/blog/verdigris-qt-without-moc.html
replies(1): >>40855529 #
4. jacoblambda ◴[] No.40852535[source]
Qt's moc can already be replaced and it increasingly is being relied on less and less as time goes on but dropping moc requires dropping all lower C++ standards or maintaining separate moc and modern-c++ versions.

And while it can currently be replaced with templates alone in fairly old versions of C++ (C++14 is the oldest I think), compile times are egregious unless you use very new, shiny features.

And as much as I am pro "move to new shiny C++", one of the big commercial uses of Qt is in semi-embedded applications like car entertainment centers where you are stuck with whatever (often outdated) toolchain your SOC source relies on. So pushing for shiny new Qt risks either splitting Qt in half or abandoning a lot of very well paying users.

5. self_awareness ◴[] No.40854005[source]
I've always wondered what's the point of "replacing moc". I mean what's the problem with moc? It's required by Qt, and completely transparent by the build system. You don't even know it's used.

I mean, GCC also has some helper tools used to compile C++ code and we don't talk about "replacing them".

Why people want to remove moc from Qt?

replies(2): >>40854995 #>>40856447 #
6. jhasse ◴[] No.40854995[source]
Bugs that come with it.
7. account42 ◴[] No.40855502[source]
Static reflection makes it much easier to build dynamic reflection though, especially without meta-compilers and excessive macro use.
8. account42 ◴[] No.40855529[source]
Using ugly macro hacks, yes.
9. jlarcombe ◴[] No.40856447[source]
Exactly. Comes up all the time and I'm never sure why. It drives most of the very useful bits of Qt.