Linked by MOS6510 on Thu 10th Jan 2013 23:25 UTC
General Development "For years I've tried my damnedest to get away from C. Too simple, too many details to manage, too old and crufty, too low level. I've had intense and torrid love affairs with Java, C++, and Erlang. I've built things I'm proud of with all of them, and yet each has broken my heart. They've made promises they couldn't keep, created cultures that focus on the wrong things, and made devastating tradeoffs that eventually make you suffer painfully. And I keep crawling back to C."
Permalink for comment 548492
To read all comments associated with this story, please click here.
RE[5]: Point by point
by saso on Sat 12th Jan 2013 10:19 UTC in reply to "RE[4]: Point by point"
saso
Member since:
2007-04-18

Except in C, there is no way to sort anything without passing a compare function to qsort. Even an array of ints needs a hand-coded, if trivial, compare function passed to it.

Actually, the fact that qsort takes a comparator function means that it is much better than a simple sort() method on an array object. It allows you much more freedom in comparing compound and complex objects, not just primitive values. How, for instance, do you sort an array of structures/objects sensibly? The language doesn't know how, so you have to provide a comparator. This is one of the less problematic features of the standard C library - providing generic interfaces for everything. If you need your ultra-fast ultra-optimized sorter, you can always code it yourself.

Reply Parent Score: 2