Why doesn't Java support pattern matching?
Why doesn't Java support pattern matching?
Objects are a way of implementing protocols without needing to know the details of the object that implements the protocol, even at runtime. Polymorphic code in OO systems is a runtime feature, not a compile time one; objects may be loaded dynamically and almost always are at some level in any large OO system, for configurability and testing if nothing else.
Also, I think what you're describing is the difference between parametric polymorphism and ad-hoc polymorphism.
class Base
Base(int i_init) -- constructor
virtual int f(int param) -- a method
class Inherit1 (extends Base)
int f(int param) -- reimplementation 1
class Inherit2 (extends Base)
int f(int param) -- reimplementation 2
class Inherit3 … (ad nauseam)
We don't need class polymorphism with inheritance, here. We can do simpler: class Base
Base(int i_init, int f_init(int)) { f =: f_init; … }
int f(int)
Or even simpler: int f(int i_init, int f_init(int)) // C-like syntax
f: int -> (int -> int) -> int -- Haskell syntax
(And don't tell me that passing function as parameters is weird, or complicated. Functions are typically way simpler than "Objects".)Why can't Haskell make it easier to express data structures? Something "turtles all the way down" introspective, like a MOF (meta-object facility, http://en.wikipedia.org/wiki/Meta-Object_Facility) would be nice.