News for hackers. Stuff that matters.
Re:Why is C++ still a very popular language in quantitative ... by veyron on Monday February 20, 2012 @03:00PM (#3613628)
Template metaprogramming still solves certain problems better than other solutions. If it is not used obsessively, then there are better languages
Re:Why is C++ still a very popular language in quantitative ... by zurn on Monday February 20, 2012 @03:24PM (#3613736)
What kinds of problems? I can't easily think of problems where C++ templates are more powerful than metaprogramming facilities of high level languages like lisp...
Re:Why is C++ still a very popular language in quantitative ... by veyron on Monday February 20, 2012 @03:35PM (#3613785)
I didn't use the word 'powerful' because powerful generally refers to expressivity. I'm most interested in performance.

C++ template metaprogramming gives you most of the expressivity of generic programming without paying a large runtime penalty (because the resolution still occurs at compile time, the compiler can take advantage of this). This is in contrast to other languages, where run-time generic programming leads to performance penalties.

Now, as the stereotypical example of how C++ template metaprogramming can actually beat standard C programming, compare the performance of C qsort with C++ std::sort.

Re:Why is C++ still a very popular language in quantitative ... by mietek on Monday February 20, 2012 @04:11PM (#3613953)
Not all expressive generic programming techniques have run time costs. The parent poster mentioned Lisp, in which macros are also usually expanded at compile time. Furthermore, Template Haskell offers type-safe compile time metaprogramming.