The Ruby on Rails and ClojureScript experts

Mar 6, 2013

TL;DR: depending on your app, using define_method is faster on boot, consumes less memory, and probably doesn’t signigicantly impact performance. Throughout the Rails code base, I typically see dynamic methods defined using class_eval. What I mean by “dynamic methods” is methods with names or bod…

Aaron Patterson has a very detailed comparison of two methods for dynamically defining methods. He looks at performance, memory consumption and other parameters. He recommends using define_method, however he points out that define_method creates a closure, so it should not hold references to large objects.

Link: Dynamic Method Definitions | Tenderlovemaking via tenderlovemaking.com