Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

rate your language

Name: Anonymous 2010-07-28 5:39

Scalability:x/10;
Performance:x/10;
Ease of use:x/10;
verbosity:x/10;

Name: Anonymous 2010-07-28 14:39

>>19
The vast majority of the time, this is because of function pointers. Compilers aren't smart enough to statically link or inline a call of a function pointer argument. The equivalent C++ code uses a template parameter instead, forcing the compiler to statically link or inline it.

This isn't because it's not possible to do this in C; it's just because it's easier and safer in C++ than in C, so people are more likely to do it. The usual example is qsort() vs std::sort(). This fails of course as an argument for C++, because it's relatively easy to write a macro version of qsort() that does the same thing. For example: http://www.corpit.ru/mjt/qsort.html

What we really need is a language that can do this automatically. You just take a function pointer like normal, and if profile data determines that the function indirection is a bottleneck, the compiler can just duplicate the function for each value of the argument and statically link and inline each version. Unfortunately, modern languages are heading in the opposite direction in terms of performance and optimization, so we might never see this happen :(

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List