Re:Reusable Software? Just Don't Write Generic Code
by finishingmove on Wednesday January 07, 2015 @06:16AM
(#8849894)
The first part of the article mixes genericity with feature-richness seamlessly. I don't necessarily agree that creating generic interfaces means bloatness, but I think a lot of the pains that the author mentions come from the way OO languages, especially the older ones, do generics (yes, inheritance abuse). Haskell is one example of a language that tries to achieve abstract and generic interfaces that are elegant (and type safe!). Another beauty of such high-level languages is that you can always create a DSL to match the abstraction level of your problem domain.
[ Parent
| on HN ]
Re:Reusable Software? Just Don't Write Generic Code
by tome on Wednesday January 07, 2015 @06:42AM
(#8849968)
I think there should be some sort of distinction between different meanings of "general" or "generic". One means "covering as many use cases as we can think of" and is criticised here. Another means "not requiring more of its inputs than necessary", which is a different thing. Haskell does the latter well, as you mention.
Re:Reusable Software? Just Don't Write Generic Code
by the_af on Wednesday January 07, 2015 @09:50AM
(#8850726)
I don't think the author truly means generic programming. He is (in my opinion) confusing terms. What he probably means is over-engineered software with too many features and/or needless extensibility that introduces unacceptable complexity.
Generic programming actually reduces assumptions, is less bug prone, and is (probably) not what the author was thinking of.
Re:Reusable Software? Just Don't Write Generic Code
by seanmcdirmid on Wednesday January 07, 2015 @09:11AM
(#8850548)
Haskell's type system is great, unless you need semi unification (equivalent to nominal subtyping and imperative assignment), then it's not so great anymore. Unification is pretty limiting.
Re:Reusable Software? Just Don't Write Generic Code
by tome on Wednesday January 07, 2015 @10:42AM
(#8851091)
Could you explain a bit more? A quick search suggests that semi-unification is equivalent to Milner-Mycroft typeability, which is polymorphic recursion, which Haskell does indeed have.
Re:Reusable Software? Just Don't Write Generic Code
by seanmcdirmid on Wednesday January 07, 2015 @06:55PM
(#8854157)
Right, but not without type inference. One of the reasons Scala's type system is quite complicated is that it can do semi-unification to achieve local type inference, at least (semi-unification is undecidable in general, and Scala makes a best effort, I believe).
How does Haskell deal with refs?
Re:Reusable Software? Just Don't Write Generic Code
by tome on Thursday January 08, 2015 @09:40AM
(#8856517)
I'm not sure what you mean. I'm not aware of any type inference difficulties with IORefs or STRefs. Polymorphic recursion, on the other hand, does often (or maybe always) require an explicit type signature.
Re:Reusable Software? Just Don't Write Generic Code
by seanmcdirmid on Thursday January 08, 2015 @05:06PM
(#8859333)
If you were to do type inference across mutable reference assignments, you would have to do some semi unification. I don't think haskell does, even ML treats refs very strangely.