2 ms·
Most programs don't need generics like most programs don't need static typing. Just use "any" and downcast.
by seanmcdirmid 12y ago
Most programs don't need generics like most programs don't need static typing. Just use "any" and downcast.
- gohrt 12y agoThat's entirely different. Generics can be replaced by code-generation (C++-style templates) in a preprocessor with no loss of safety, or by boring copy-paste (with some loss of safety :-(). non-static typing is a massive loss of safety.
- pcwalton 12y agoStatic typing can be replicated in a dynamically typed language with a preprocessor too. (For example, see TypeScript.)
- seanmcdirmid 12y agoTemplates/macros/preprocessing do sacrifice separate compilation and separate type checking; so your error messages might not be comprehensible, your compile times can be much slower, and...you need source for your generic container. Rob Pike probably knows the drawbacks of that approach well and I doubt he would go there.