Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It would definitely be possible, but I would really hate to see coupling like that added to ruby. I also worry that it would make it too magical and difficult to figure out what code is running, where and when. Debugging an issue deep in the bowels of that is a scary thought.


> to ruby. I also worry that it would make it too magical and difficult to figure out what code is running, where and when

Coming from both python and statically-typed languages, your description 100% squares up with every experience I've had with ruby

Folks are free to throw stones at the Spring Framework similarly, it's not out of bounds, but ruby seems to embrace the monkeypatch


> ruby seems to embrace the monkeypatch

How recent were your experiences with this? In recent years I've seen monkeypatching treated as more of an antipattern. If you are on a project where people are doing that without very good reasons, that says more about the team than the language.


It is still prevalent enough that when developing Ruby JITs it can be worthwhile delaying compilation until the framework has started up and finished invalidating all your method lookups, or changing your invalidation strategy to handle new methods being defined on Object without invalidating all your inline caches.


I think that’s a misconception of people who don’t understand the underlying language/framework (yet).

How much magic is really going on, especially compared to for example JPA/Hiberbate, or any of the aspect orient projects?


Monkeypatching was common a decade ago. Now it’s more limited to things that try to be language or framework extensions, like ActiveSupport or gems extending ActiveRecord. The whole point of those is to deeply integrate.

Metaprogramming like looping over an array to dynamic create methods is far less common. It definitely makes me cranky when I can’t find a method definition. ORMs are one of a few exceptions where the utility justifies it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: