3 ms·
"For example, a+a+a+a can become a*4 and even a<<2 if a is an integer. But if one creates a class with operators, there is nothing to indicate if they are commu
by tedunangst 17y ago
"For example, a+a+a+a can become a*4 and even a<<2 if a is an integer. But if one creates a class with operators, there is nothing to indicate if they are commutative, distributive, or associative. Since one isn't supposed to look inside the object, it's not possible to know which of two equivalent expressions is more efficient."
But it is ok (expected even?) to look inside the implementation of every function in a non-OO language?
Explain how I am to know which to choose from the equivalent C code of add(a, add(a, add(a, a))) or multiply(a, 4)?
There are reasons to dislike aspects of C++, but the "omg operators are hard" meme is the biggest dumbest straw man around.
- dasil003 17y agoThe whole article has a whiff of bullshit even if it seems truthy at times. Yes, OOP is a great fit for GUI programming which helped it rise to prominence, however the rest of it is spoken like someone who has never really done any serious OOP. I think it's fair to say that OOP is not significantly different from procedural programming, and certainly can't be considered universally better. It just provides some additional tools for structuring the code and data, however it doesn't offer any deep and powerful benefits like functional programming or s-expressions provide.