Answer the question
In order to leave comments, you need to log in
There is an opinion that metaprogramming does not take place in web projects. Is it so?
Actually the question is in the header. If so, what is it for? And how can it affect a high-load project? If the speed, namely interpretation (not development), falls then by how much in percentage if the implementation were without it? Would the speed drop be essential to not use metaprogramming? Maybe someone has real experience comparing all the pros and cons?
Answer the question
In order to leave comments, you need to log in
This is not true. Metaprogramming, as elsewhere, serves the web to reduce the amount of code. The speed depends more on the code than on the language (as always in the interpreted ones). I worked in a team where there were about 10 projects using metaprogramming, everything worked like clockwork.
Metaprogramming can help structure your code and improve performance. Let's say you have a module (concern) that adds some functionality to different objects. Let's call them objects and subjects.
One class may have
include MyModule
act_as_object
include MyModule
act_as_subject
module MyModule
def act_as_object
define_method :obj_meth_1 do; end
define_method :obj_meth_2 do; end
end
def act_as_subject
define_method :subj_meth_1 do; end
define_method :subj_meth_2 do; end
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question