Tue, 19 Oct 2010 21:30:44 +0100, div0 wrote: > On 19/10/2010 21:24, Paulo Pinto wrote: >> Am 18.10.2010 22:49, schrieb bearophile: >>> Nick Sabalausky: >>> >>>> It's amazing how many software houses/departments don't do that. But >>>> of course, if they don't it's their own damn problem. >>> >>> They want low-salary programmers, so they will avoid languages that >>> may lead to higher salaries. This means uncommon languages (where >>> programmers are more rare) or languages that may need the ability to >>> read (or even write) "harder code" (like inline assembly). >>> >>> Bye, >>> bearophile >> >> This is one of the reasons why Java has become such a huge language in >> the IT world. > > yeah but to be fair, I work in a fully C++ shop and only 3 (maybe 4) of > us out of 18 will *ever* write template code. > > even for really trival stuff. > > In my xp, most c++ programmers just don't/can't get templates and I very > much doubt that awkward syntax is the root cause. > > if you are one of those people why whould you chose a language with > templates? they are off no dam use to you.
Templates are used for at least two different purposes - to provide 1) (generic) parametric polymorphism and 2) (generative) metaprogramming code. Often the parametric version is enough (e.g. simple uses of collections). The first case is "optimized" in many modern language. For instance in Scala polymorphic collections are rather simple to use: // using namespace std; val l = List(1,2,3) // list<int> l(1,2,3); println("The contents are: ") // cout << "The contents are: "; println(l.mkString(" ")) // for (list<int>::iterator it = l.begin(); it != l.end(); it++) // cout << *it << " "; // cout << endl; println("Squared: ") // cout << "Squared: "; println(l.map(2 *).mkString(" ")) // for (list<int>::iterator it = l.begin(); it != l.end(); it++) // cout << (*it)*(*it) << " "; // cout << endl; Typical use cases don't require type annotations anywhere. The only problem with high level languages is that they may in some cases put more pressure to the optimizations in the compiler. What's funny is that the Scala developer here "implicitly" used terribly complex templates behind the scenes. And it's as simple as writing in some toy language. Overall, even the novice developers are so expensive that you can often replace the lost effiency with bigger hardware, which is cheaper than the extra development time would have been. This is many times the situation *now*, it might change when the large cloud servers run out of resources.