Article View: pl.comp.objects
Article #15397Jeszcze o C++ templates i ich zwiazku z ....
From: A.L.
Date: Sun, 03 Sep 2006 22:27
Date: Sun, 03 Sep 2006 22:27
33 lines
2264 bytes
2264 bytes
... ML i Lispem "On the other hand, just because templates are the best C++ has to offer doesn't mean they're good. It turns out that all the problems templates solve were already solved better, before templates were ever introduced, by other languages. In fact, the kludgey way templates work precludes C++ programmers from a lot of the good stuff that nicer solutions have. [...] For one thing, templates hurt the C++ compiler's ability to generate efficient code. It might surprise you to hear that, considering that C++ is "efficient" while functional languages like ML and Scheme are "inefficient," but it's true. C++ templates hide your intentions from the compiler: did you mean type abstraction? Did you mean a syntax extension? Did you mean constant-folding or compile-time code generation? The compiler doesn't know, so it has to just blindly apply the copy-and-paste strategy and then see what happens. In ML or Scheme, though, aside from the individual benefits described above, the simple fact that you're telling the compiler what you want to achieve lets it optimize for you much more effectively. [...] But from a broader perspective, realizing that templates are really just a C++ version of Lisp macros geared towards generating type declarations rather than extending C++'s syntax helps you understand the wider history of programming languages rather than just knowing the flavor of the month (which is rapidly becoming the flavor of last month!)... Artykul "What's Wrong with C++ Templates?" tutaj http://people.cs.uchicago.edu/~jacobm/pubs/templates.html A.L.
Technical Details
Message-ID:
<0elmf2h54pl11i82jrlrjeifeaue4np2i6@4ax.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!news.germany.com!sn-xt-sjc-03!sn-xt-sjc-01!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!news.germany.com!sn-xt-sjc-03!sn-xt-sjc-01!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail From: A.L. <alewando@fala2005.com> Newsgroups: pl.comp.objects Subject: Jeszcze o C++ templates i ich zwiazku z .... Date: Sun, 03 Sep 2006 17:27:15 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <0elmf2h54pl11i82jrlrjeifeaue4np2i6@4ax.com> X-Newsreader: Forte Agent 3.1/32.783 MIME-Version: 1.0 X-Complaints-To: abuse@supernews.com Lines: 35 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit