|
|
|
|
|
by jacquesm
5811 days ago
|
|
Generic programming is a way of writing code, not a thing that your language supports or you can't do it. I can write perfectly re-usable C code that is also very efficient by relying on the pre-processor to customise the code to the exact types and conditionals required for the situation at hand. It's a bit like saying you can't write functional code unless you use a functional language. |
|
That's not to say you can't write C in a generic way, but "generic programming" means something specific to computer scientists and has certain prerequisites.
And you can't write functional code without a functional language, without building a functional language on top of your language (which may not even be possible, e.g. you can do functional-ish stuff in C because of function pointers. Without them, you'd be stuffed.)
You can write functional code in a "non functional language", if by functional language you mean "Haskell, ML or Scala". But you need certain features like function pointers to do it, and in that sense you do need a functional language. Same for generic programming - you need certain features.