News for hackers. Stuff that matters.
Re:Scalable Program Architectures by loup-vaillant on Monday April 14, 2014 @05:14PM (#7589000)
Fun fact: I have known this intuitively since forever, but only recently realized that when I say "generic", most programmers I know tend to hear "exhaustive", and recoil in horror; while I really meant "generic".

Now, I also know why I like parametric polymorphism, and dislike subclass polymorphism: the first is generic, while the second is exhaustive.

Re:Scalable Program Architectures by tel on Monday April 14, 2014 @05:18PM (#7589026)
> Now, I also know why I like parametric polymorphism, and dislike subclass polymorphism: the first is generic, while the second is exhaustive.

I'm going to steal that. I love it.

Re:Scalable Program Architectures by mushly on Monday April 14, 2014 @09:06PM (#7589788)
What's the difference between "generic" and "exhaustive," and where can I read more about all this stuff?
Re:Scalable Program Architectures by loup-vaillant on Tuesday April 15, 2014 @03:11AM (#7590692)
Imagine you want to process a list of foobarbaz, where elements can be foos, bars, or bazes.

Exhaustion is when you write foo specific code, bar specific code, and baz specific code. Then your list-processing facility is general because it handles all the cases. A typical way to do that in practice is to use subtype polymorphism, with the class inheritance mechanism: have a foobarbaz interface, a foo class that implements it, a bar class that implements it, and a baz class that implements it. Each with their own code.

Genericness is when you ignore the foobarbaz specifics altogether: your code doesn't even mention the types. A typical way to do that in practice is to use parametric polymorphism (generics in Java, templates in C++). See C++'s Algorithm library for an example, or the standard Prelude from Haskell, or the OCaml standard library.