Re:JIT and Ruby's MJIT
by t-writescode on Friday December 06, 2019 @09:54PM
(#21728162)
New Rails dev here: I believe the entire ActiveRecord model is constant monkey patching.
[ Parent
| on HN ]
Re:JIT and Ruby's MJIT
by FooBarWidget on Friday December 06, 2019 @10:13PM
(#21728228)
Long time Rails dev here. I believe not. The Rails core devs have long known that monkey patching is not thread safe, and blows Ruby method caches, so they already reserve monkey patching for initialization time.
Re:JIT and Ruby's MJIT
by thomasfedb on Saturday December 07, 2019 @01:42AM
(#21728876)
I feel that the definition of "monkey patching" doesn't (or shouldn't) cover what Rails does in AR. Monkey patch suggests a change of behaviour over what was initially intended, however dynamic method generation in AR is very-much part of the intended API.
That said, there are plenty of Rails apps that do monkey patch Rails internals, for better or worse.
Re:JIT and Ruby's MJIT
by toasterlovin on Friday December 06, 2019 @10:16PM
(#21728235)
Do you have something specific in mind? From my understanding of ActiveRecord, most of the method generation should happen the first time the class is defined.
Closer to the first time it's used. Schema gets queried and methods get added the moment you do the first query on the model normally.