Hacker News new | ask | show | jobs
by stevebmark 2094 days ago
I really wish Ruby would grow up and deprecate method_missing
4 comments

> I really wish Ruby would grow up and deprecate method_missing

method_missing is a deliberate and principled part of a message-passing approach to object orientated programming that gives you powerful options for composition and delegation.

You can say you don't prefer this style of programming, but it's not well-informed to say it's down to immaturity or ignorance of alternatives on their part.

What do you mean by "powerful". Meaning you can type less code. You can still do delegation by writing it out yourself. Or you can also use the Delegator or Forwardable classes to save some typing. I'm not sure what meta programming they use under the hood. Probably define_method or method_missing.

Also, people always forget to throw NotImplemented errors which can lead to some fun to track down bugs if you make a typo sending a message. Which I guess is why you pretty much have to write tests for everything in ruby. This kind of stuff would be caught by a compiler in other languages.

Disclaimer: I don't buy into the idea of "message passing" or a lot of OOP. They're the microservices of programming languages.

> I don't buy into the idea of "message passing" or a lot of OOP. They're the microservices of programming languages.

Then this probably was never the right language for you in the first place.

But let's not say that people with different opinions about language design to you own need to 'grow up'.

Metaprogramming is an important part of ruby, so method_missing stays.
Why? method_missing is one of the fun features of the language
What's wrong with it?
Nothing. There is nothing wrong with it at all except he "doesn't like" it.