4 ms·
I have been working with Ruby for over a decade and IMO most metaprogramming is the worst part of Ruby code. It makes code very difficult to reason about outsid
by specialp 4y ago
I have been working with Ruby for over a decade and IMO most metaprogramming is the worst part of Ruby code. It makes code very difficult to reason about outside of runtime and makes unclear traces when something does go wrong. Now I know it can be done right, but I think the Ruby community ran too much with DRY (Don't Repeat Yourself) and "clean" minimal syntax at the cost of maintainability and readability.
It also makes it hard for tools to reason about what is being run as well when you have stuff running in `instance_eval` contexts and `method_missing` being abused. So now here we are trying to unravel that by trying to make the interpreter smarter with caching to improve performance but if I had to turn back time, I would reverse every instance where one tried to be clever with metaprogramming in the name of syntax.
- giraffe_lady 4y agoYeah I kinda knew I'd regret mentioning any specific feature of ruby that one in particular. Anyway it doesn't matter. The point was that they presumably have identified certain things ruby does well for them and have invested heavily in them. If ruby does other things less well then abandoning ship for an unknown set of tradeoffs is a riskier move than improving the specific weaknesses that are their obstacles. What ruby's inherent strengths are or even if they exist at all doesn't matter as much as their investment and expertise in them does.