4 ms·
C++ has a good type system? C++ templates are just a copy-paste find-replace-all hack around type-system, they don't typecheck at all at the generic level. Ther
by pkolaczk 13y ago
C++ has a good type system? C++ templates are just a copy-paste find-replace-all hack around type-system, they don't typecheck at all at the generic level. There is no notion of type variance nor dependent types. Not to mention many warts inherited from C (like being able to implicitly cast char arrays to booleans). It is IMHO much worse than even Java's (which is also not good).
- EpicEng 13y agoYet they are extremely powerful. Whatever their flaws may be, I have worked with your preferred version of templates (C# generics) and, let me tell you, they are inferior in every practical way.
- pkolaczk 13y agoHuh, where did I say my preferred version of templates were C# generics? As of C++ templates being extremely powerful - I agree. But this is a similar kind of "powerfulness" as C macros are, only little safer. Technically they are still just a fancy macrogenerator working at the AST level instead of lexer level, knowing nothing about the types (you even have to tell it which symbols are the types, because it cannot reason it out from syntax). IMHO it is years behind true generic typesystems like in Haskell, OCaml or Scala and calling it a "type system" is an exaggeration.