4 ms·
Isn't the real problem that Ruby's "magic" a lot of the time relies on monkey-patching stuff? I mean, Javascript's modules also are dynamically executed and th
by bernawil 7y ago
Isn't the real problem that Ruby's "magic" a lot of the time relies on monkey-patching stuff?
I mean, Javascript's modules also are dynamically executed and then returned as a singleton module object (also cached, so only the first require actually runs the code before the module export). This means you can make a module which requires other modules and monkey patches methods inside them (this is how mocking actually works), wrecking havoc amongst all other dependencies, but library authors just don't.
- vidarh 7y agoThe more in-your-face monkey-patching went out of favour many years ago. Most newer Ruby libraries make you explicitly "opt in" to changes by e.g. including a module and/or contain any monkey-patching in separate files that needs to be explicitly require'd if you want that behavior. It's rarely a problem in practice.