Maybe I just don't 'get it;' to me, this is that dark underbelly of Ruby's Perlness oozing out.
Magic operators are one of Perl's worst features & now we can make them even worse in Ruby by creating our own set of unmaintainable overloaded magic operators. Everyone can create their own private hell to invoke on every other Ruby coder!
Put down teh overloaded magic operators and step away from the keyboard.
:)
Anyway, thanks for the post & for your blog in general; lots of helpful, well written articles.
To those who are accustomed to languages without operator overloading, they are magic. To the rest of us, they are just method names plus a bit of special syntax.
It's not that I'm not accustomed to them or don't know how to use them. It's that I believe they are the embodiment of bad coding practices. They are esoteric shortcuts that make code easy to write and much harder to maintain.
They are here-and-now solutions that ultimately cost more time and effort in the long run.
Because some Perl coder wanted to type
$>
instead of spending a fraction of a second more and type
$EUID
anyone attempting to use that code forever after needs to address the micro meanings of the syntax itself. There's no expressiveness in the syntax, no way to understand the complex meaning of the operator without a reference.
These operators are dramatically different than basic operators. They require much more context and are much less intuitive.
I know the other side of this argument is that it's akin to learning any other syntax of a language. I can understand the argument and I don't disagree. But personally, I find the maintainability of any code drops off a steep cliff once it starts using magic operators.
Personally, I want to deal with finding solutions to problems, not deal with the esoteric symbols that have been arbitrarily associated with some abstract and complex concept.
+/-url("...") in the context of a DSL for building allow/deny rulesets is considerably more self-descriptive than your example from another language that isn't even an operator, just a badly named variable.
Personally, I would have gone with allow/deny instead of +/- but I'm glad the choice is available. It certainly pays off for numeric types or DSLs that involve complex nested expressions e.g. parsing grammars.
Fair enough. I was pretty fast and loose. Thanks for the correction.
My magic vars/operators mix & match was inaccurate, but still appropriate; the point still remains, overloading operators seems risky for long term maintenance if it's not used cautiously.
It's clever & no doubt has its usefulness, but as the author of the article implies, it can be (ab)used. And I guess I hopped off the train right there.
I think I'll take a look at this again tomorrow with fresh eyes & see what I'm missing.
Magic operators are one of Perl's worst features & now we can make them even worse in Ruby by creating our own set of unmaintainable overloaded magic operators. Everyone can create their own private hell to invoke on every other Ruby coder!
Put down teh overloaded magic operators and step away from the keyboard.
:)
Anyway, thanks for the post & for your blog in general; lots of helpful, well written articles.