4 ms·
> Python has all the same features and allows you to write code that is equally horrible (or powerful), but it benefits from a cultural bias in favor of simplic
by mypalmike 9y ago
> Python has all the same features and allows you to write code that is equally horrible (or powerful), but it benefits from a cultural bias in favor of simplicity.
It's not a cultural bias. It's a critical difference in the language designs.
In python, monkeypatching is scoped to a module.
In Ruby, monkeypatching is global to the execution environment.
So in Python, you can look at the source code for a module in isolation and deterministically reason about what it does.
In Ruby, you can't. Because you can't know what the execution environment will be.
IMO, it's the main reason why Ruby projects become harder to manage as they grow. Somewhere, someone is monkeypatching, and reasoning about the code becomes harder and less local. I spent 2 years with Ruby and will never use it again if I can help it.
- crdoconnor 9y agoMonkey patching can still make horrendously unreadable python code. I agree that it's better that its scope is localized, but I still think that it's more important that monkey patching is used sparingly, and that requires a cultural bias against it.
- raverbashing 9y agoYes, there are few (but important) use cases for it - Patching a library for testing purposes - Fixing a bug in some library you can't change
- mbell 9y agoMonkeypatching in Ruby can be localize if you want it to be, see refinements.