Hacker News new | ask | show | jobs
by inopinatus 797 days ago
There's a very simple reason. Writing explicit abstract methods ensures that both the parent and its subclasses can still use "method_missing" without having to special-case the landmine¹.

> Ruby also provides inheritance hooks that could conceivably be used to detect the existence of methods at load time

This misses numerous corner cases e.g. refinements, or the dynamic include/prepend of modules (which may even be generated anonymous modules). One may not write such code often in applications, but this happens routinely in the guts of many frameworks and libraries, and not just Rails.

Most attempts to introduce type checking or anything resembling it into Ruby run into the wall of "load time is run time".

___

[1] corollary: consider writing a respond_to? that returns false for the abstract method(s)