Am Mittwoch, 15. Oktober 2008 00:34 schrieb Derek Elkins: > It's not technically true. Type classes and interfaces a la Java are > very fundamentally different neither is remotely capable of doing what > the other does.
Could you elaborate on that, please? I always understood Java's interfaces to be somewhat similar to type classes (and I learnt the bit of Java I know before I even knew the term "Functional Programming", never really got the whole OO thing though). An interface, I thought, is a contract stating that the classes implementing that interface provide certain operations (obeying some rules). If there's more to interfaces, I'm happily unaware of that :) In what way is that "very fundamentally different" from type classes? As the languages as a whole are fundamentally different, that similarity is of course rather superficial, so I will not say that stressing it is beneficial, but I'm not convinced it is detrimental either. > > I strongly agree with the thrust of your email. This "type classes are > kinda like interfaces" meme is horrible. Because of the tendency to confuse OO programmers learning Haskell, or is there a deeper reason? (Answer to this question could be superfluous after addressing the above) > For example, this > is a line from RWH: "Typeclasses may look like the objects of > object-oriented programming, but they are truly quite different." Also > later there is another sidebar along those lines. > Now that is something I wouldn't have dreamt of. If anything, I would relate objects to values (except that objects tend to be mutable). Thanks, Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe