On Wednesday, 15 February 2012 at 15:35:37 UTC, bearophile wrote:
foobar:

1. D templates are an enhanced version of C++ templates which are a poor design. The problem stems IMO not from issues with OOP but rather with the horrible idea of C++-like templates. Other languages have *much* better solutions which integrate better.

C++ is one of the most commonly used languages, probably there are billions of lines of C++ in use, and C++ library code uses templates often, so despite the well known flaws of C++ templates (bloat, bad error messages, etc), they are somehow "good enough", they aren't horrible.

Compared to C++, D templates introduce constraints, a better syntax, and more uniform/sane semantics of details. Bjarne Stroustrup is still trying to invent simplified Concepts to improve C++ templates, to give them "static" types.

Java generics, C# generics, Ada generic programming, C++ templates, ML polymorphism, Haskell type inference with type classes, Haskell template extensions, are designed to satisfy different needs and constraints. All of them are used and useful, none of them are perfect.

Bye,
bearophile

I beg to differ. I was talking about the *design* aspect of templates and you seem to agree that it is flawed. the design *is* horrible and can be compared to other better designs. The fact that it is used in so much software is a completely orthogonal matter. Most people use qwerty keyboards (including me) but that does not mean it's the superior design. on the contrary, it was *intentionally* designed to be flawed for historical reasons that are no longer relevant. what is "good enough"? it is highly subjective. Is it enough to be commonly used by many people? what other criteria would be required to classify as good enough and not worth improvement? should we never strive to achieve better designs?

I don't know Haskell and won't comment on the above mentioned features but regarding generics (e.g in C#) - they have no conflicts with OOP and are a good feature.

Reply via email to