If monkey patching is permitted in both Ruby and Python, why is it more controversial in Ruby?

前端 未结 8 1391
一向
一向 2021-02-05 12:34

In many discussions I have heard about Ruby in which people have expressed their reservations about the language, the issue of monkey patching comes up as one of their primary c

相关标签:
8条回答
  • 2021-02-05 12:55

    It's a technique less practised in Python, in part because "core" classes in Python (those implemented in C) are not really modifiable. In Ruby, on the other hand, because of the way it's implemented internally (not better, just different) just about anything can be modified dynamically.

    Philosophically, it's something that tends to be frowned on within the Python community, distinctly less so in the Ruby world. I don't know why you assert that it's more controversial (can you link to an authoritative reference?) - my experience has been that monkey-patching is an accepted technique if one where the user should be aware of possible consequences.

    0 讨论(0)
  • 2021-02-05 13:00

    "Does Python include different types of safeguards to minimize the risks of this feature?"

    Yes. The community refuses to do it. The safeguard is entirely social.

    0 讨论(0)
提交回复
热议问题