4 ms·
Maybe I'm just lucky, but I've never seen operator overloading abused, and I've written my fair share of C++. Bad developers usually don't learn about these thi
by mattgreenrocks 12y ago
Maybe I'm just lucky, but I've never seen operator overloading abused, and I've written my fair share of C++. Bad developers usually don't learn about these things in the first place, they just spew mountains of poorly-abstracted code.
Ruby lets you do far worse things if you dig deep enough, but nobody ever complains about that.
- jaegerpicker 12y agoSlight counter point re: ruby, I complain A LOT about ruby's and the communities tendency to monkey patch everything. It's a dangerous practice that needs to be REALLY well thought out. just like C++ and the operator overloading, I've had bad and good experiences with both. I don't think they need to be removed from the languages but I do think good experienced developers should loudly and quite often proclaim the dangers of over use.
- mikeash 12y agoI think it comes down to culture, not language features. Objective-C allows much the same monkey-patching craziness as Ruby, but the feature is almost always used to just add additional convenience methods to system classes in a fairly safe and sane manner. You can do much worse (and I certainly have), but it's pretty rare.
- andybak 12y agoSame and possibly more so in Python. Monkey patching is regarded as a last resort in clever libraries that need to do things that would be impossible any other way. They are generally clearly signposted as 'smelly but unavoidable'.
- jaegerpicker 12y agoI agree, I'm a python/django developer in my day job and a ObjC/iOS at home. Both are just a easy to monkey patch as ruby but it's much less used. It's one of the reasons I prefer python to ruby.
- mattgreenrocks 12y agoI'm with you there. I hate when anything extends built-in types. Since all code uses built-in types, you can quickly end up in debugging hell.
- Symmetry 12y agoI've always thought of the stdlib overloading of << in streams to be, well, maybe not an abuse on the scale you see in the obfuscated C contests but at least a place where operator overloading makes code harder to read and understand.
- Pxtl 12y agoHonestly, I can see why C++ overrode it in the first place though - does anybody really give a crap about the "<<" operator? Why does a language need to dedicate a whole operator to bitshifting? I assume Stroustrup et al took a look at the meaningless "<<" and decided it was available for whatever use they saw fit.
- steveklabnik 12y ago> Ruby lets you do far worse things if you dig deep enough, but nobody ever complains about that. Well, people _used_ to, but we developed cultural tendencies to reduce those kinds of issues. The last time I was bit by a bug like this was years ago.