4 ms·
I am not convinced with your conclusion that metaprogramming does not make code less readable. My personal experience speaks otherwise. Metaprogramming has a l
by sidkshatriya 7y ago
I am not convinced with your conclusion that metaprogramming does not make code less readable. My personal experience speaks otherwise.
Metaprogramming has a lot of "magic" associated with it which makes code hard to debug and understand sometimes.
You cite the success/popularity of Ruby as an example of why metaprogramming does not make code less readable. The popularity of a programming language does not mean that the language does not have significant warts. There are cultural and historical factors that make a language popular. Availability of web frameworks (e.g. Rails) are another powerful influence.
For the large part, Ruby code _is_ understandable/readable if you avoid metaprogramming. Once you have a large codebase and advanced frameworks that make heavy use of metaprogramming you can quickly get lost. There are lot of "effects at a distance" i.e. one library changes something and that can break something far away and potentially not even connected. Would you say your code is readable? No, the code is not readable because it runs in a totally unexpected manner.
My theory is that beginners decided to learn Ruby because it was easy to start with and it had a lot of powerful framesworks (e.g. Rails). The learning curve is gentle. But pretty soon when you start writing advanced ruby or start using advanced frameworks things can get complex.