Java has made you soft if you can't program without auto-complete rapidcoder :P. |
Who's saying I can't code without autocomplete? I can, but it is slower.
In C++ you don't have choice, considering how badly autocomplete works. It helps usually only in trivial cases, where you don't need it anyway.
Templates are turing complete, saying Java generics are easier to debug and has auto-complete is like saying my language XXYY can auto-complete a program simply by naming the source file what you want it to do. |
For 99% of code out there being turing completeness is less important than having good tooling. If you want Turing complete generics, Scala has one. Built on top of Java. So Java can definitely do it. BTW: As for Scala, Scala 2.10 has something more - typesafe macros, which offer much more flexibility for metaprogramming than templates.
C++ templates are used for Template Metaprogramming, Java generics are used for convenience of syntax. |
Nope. C++ templates are used mostly for convenience of syntax, i.e. to implement library goodies that are in STL and Boost: strings, containers, smart pointers, atomics, etc. They have nothing to do with metaprogramming. These are all the things that Java generics are used for. Metaprogramming is academic topic - people talk about it at OOPSLA or write nice books, but it is rarely used in production level software.
C++ template metaprogramming is like a car that can swim. Technically sophisticated. Probably complex to operate. Probably less safe. Obviously more functional than an ordinary car. But, honestly, how often do you need one, if there are bridges?
I thought rapidcoder was arguing that they were the same? I probably misunderstood, sorry... |
I was not saying they are the same. I'm saying they are used mostly for the same purpose. And for the purposes they are used for, Java generics are better. For real metaprogramming, templates feel very limited compared to what other languages offer (LISP, Scala, even Python).
BTW: As we are at metaprogramming, Java can do it too, and does it, but not with generics. Things like ASM / CGLIB / instrumentation agents are doing it for years. And it is again stronger than templates, because they can modify/generate code dynamically, not only at compile time.