by RightWingRabble · 10y ago · 0 comments
- It used to be that Qt was massive; because it existed before ubiquitous, usable STL implementations, Qt had to essentially also ship its own C++ standard library. Which meant that you couldn't use standard C++ strings, you had to use QString, and so on. This is less true with Qt 4 & 5, but reputations stick around.
- Often-times C++ APIs are a pain, even if you are using C++, many people have the opinion that the API exposed should be C.
And the STL data structures are sometimes kind of unwieldy:
if (dict.find(key) != dict.end()) { ... }
is lame compared to the easily understood: if (dict.contains(key)) { ... }
Not to mention all the stupid inconsistencies: // std::vector has no sort function, haha!
std::sort(std_vector.begin(), std_vector.end());
// std::sort doesn't work on std::list, haha!
std_list.sort();
And my favorite annoyance, the fact that std::vector::size() returns unsigned int, despite the fact that for practical purposes you aren't going to get anywhere near even 2 billion elements without running out of memory (or other performance problems), so I'm stuck writing for (unsigned int idx = 0; idx < v.size(); ++idx) {...}
or omitting the "unsigned" and getting lots of compiler warnings. I get why they would have done it; I would have done it too. Until I used Qt, then I like how everything is simply int. I suppose if you are doing physics simulations or something you might need something different, but it's the rare GUI program that needs unsigned int for size.I agree, STL has done the "right" thing with sizes; of course negative sizes are meaningless. The problem is, Qt's way is so much nicer to use, even though it is obviously "wrong." Type three characters, done. Putting "int" in your headers, it's obvious what's going on--you're getting a number back. I suppose std::size_t is obvious, but it's hard to read, and I hate typing underscores. Again, more correct, but I hate doing it, which is just another reason why Qt is such fun to use compare to STL.
std::list's iterator type: http://en.cppreference.com/w/cpp/container/list
std::sort's iterator requirements: http://en.cppreference.com/w/cpp/algorithm/sort
All the different types of iterator: http://en.cppreference.com/w/cpp/iterator
(This might seem like needless nitpicking to some; to me, it's more like knowing why you can't, say, seek on a socket.)
Even being conservative, say you had a struct of size 24 bytes (e.g. 3 doubles x, y and z) then now you're up to 48G.
So yes, there are very few situations where you'll have meaningful data that would fill a vector indexed by signed ints without running out of memory first.
- I'm in the camp that thinks widget libraries for C++ should be workable in C.
- I'm big on minimalism, and being strongly aware of "90% of programs out there are bloated", and was horrified when I had to install a tiny Qt based program in ubuntu, and it required me to install a gazillion packages that looked like they belonged to Qt. (I don't remember the details).
- I always keep looking for C programs that can do in a couple thousand lines, what takes tens of thousands of non-C code for other programs to accomplish. I'm fairly aligned with the suckless philosophy, although I may not 100% agree with them. (suckless website would give you a good idea of what I'm talking about).
The moc is to effectively extend C++ with signals and slot at a language level. I'm not crazy about the moc, but I love signals and slots. The only alternative is slow-compiling templates like boost signals and slots, which also have less than compelling syntax.