This is why C++ is so great for big projects. You start to run into many cases where overloading operators is the only natural thing to do, and almost all of the semantic information (type, constness, etc.) is kept track of for you so if someone later comes and tries to modify a const parameter in some method, for example, the error is caught in compile-time! Sure, it takes a lot more code than Python or Ruby or PHP, but it definitely has its advantages.
The trouble with the C++ paradigm that the implementor of a class does a bit more work so that the user of a class doesn't have to is that it's recursively extra work: I do extra work in a low-level class so it's user can do less - but wait! I'm the user of this class. And in the class in which I use the class I just worked hard on, I further have to do extra work for the benefit of the users of the second class. And so on - a hall of mirrors of extra work. Not to say that it's zero-sum, but the effect is more one of shifting the work downward in the hierarchy and I only get a net benefit if I reuse the most basic classes roughly at least 3 times. Not all classes are created for re-use; some are created just to divide up the code into smaller human-readable chunks, and that's where the extra work for the implementor of a class is more overhead than it saves.
2 comments
[ 4.6 ms ] story [ 12.1 ms ] thread