Hacker News new | past | comments | ask | show | jobs | submit login

I'd rather say templates are a hack to get generics in C++, because C++ lacks real generics contrary to eg. Java, C#, Haskell or Scala. Templates used as generics are limited in a way that the typechecker can't reason about generic types, only concrete types, which leads to horrendeous error messages and makes it impossible to prove generic library code type-safety. Type templates are templates, not types.

On the other hand templates used as a metaprogramming tool fall behind any modern macro system.




Rust is getting there but still lacks type-level integers, and macros are waiting for macros 2.0. It would also be neat to have the ability to run any function at compile time, but I don't think that's in the cards.


True, but as someone that spends the majority of his programming time between Java and C#, with C++ only when required, I do miss their power.

Also it is way better with latest standard improvements.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: