3 ms·
This non-sequitur of a reply is getting pretty tired on C++ articles. Perhaps you could explain how this feature is a sprawling mess exactly? In my opinion, n
by Negitivefrags 7y ago
This non-sequitur of a reply is getting pretty tired on C++ articles.
Perhaps you could explain how this feature is a sprawling mess exactly?
In my opinion, not only is the feature easy to understand for beginners, but it also :
1) Simplifies code - less code to write means less code to have bugs
2) Prevents people making mistakes - incompatibly defined comparison operators wont happen with <=>
3) Gives a speed boost - in some algorithms it's faster to do a<=>b rather than a < b and b > a.
You could find a deep dive article just as long about the minute details of comparison for practically any language.
- simias 7y agoI agree. I'm usually the first to shudder at C++'s insane complexity (and the fact that they keep piling more on top with every new standard) but this change feels rather natural, intuitive and a significant quality of life improvement. Sure, it adds the `<=>` operator but I think once you've been explained once what it does it's not to hard to reason about it. That still leaves the problem of technical debt of course: for the decade to come C++ devs will have to deal with both the legacy and the modern version of comparison operators and they'll have to learn to understand and deal with both.
- amelius 7y agoWell, if you really want to be convinced how hairy C++ has become, just have a look at the implementation of the Boost libraries.
- cmrdporcupine 7y agoWith every revision of the C++ standard Boost becomes both less hairy and less necessary. The direction of the language is towards greater cleanliness and consistency.
- amelius 7y agoYes, but it shows that the problem still exists.
- CJefferson 7y agoExcept, when I define templates code I need to handle classes that haven't defined <=>, and it isn't automatically created. This is, to me, the biggest problem with c++. Some stuff would be great if it had been there from the start, or you are working a code base. Which can require all code (including all libraries) make full use of all modern c++ features. But new feature, in my experience, never stop you having to handle older features.
- debatem1 7y agoI didn't say <=> was a sprawling mess. I said C++ is a sprawling mess, and it surely is: C++20 will be at least as big a change as C++11, and the feature laundry list seems determined to grow. That's great for people who work on a codebase, but makes bridging the gaps between C++ codebases harder with every passing year. And make no mistake: I 100% guarantee there will be bugs arising from the mixed use of <=> and traditional operators.