4 ms·
I take issue with the 'monkeypatching core classes isn't magic' conclusion. I'd define "magic" in this sense as something that looks like it does one thing, but
by 6gvONxR4sf7o 5y ago
I take issue with the 'monkeypatching core classes isn't magic' conclusion. I'd define "magic" in this sense as something that looks like it does one thing, but actually does another.
In python, if I see `print(5)`, I should know what that will do. Now, it's possible to do all sorts of magic and make it do something different (like print "five"). The reason that hijacking `print(5)` is magic is because when I look at it, I have reasonable expectations that are subverted.
The reason that magic is often considered bad is that if my code is supposed to subvert my expertise, then my expertise suddenly isn't useful to getting my job done. If I want to make it do something else, or debug it, I won't know where to go, because I should know how to debug `print(5)` or change it to `print(6)`, but now I don't know my way around my tools.
Maybe it's a connection to black boxes. If a reasonable user can't see how or why your magic works, and can't debug or direct your magic, it's too magical. Yes, that's subjective, but too bad. Maybe "opaque" is a better word.