News for hackers. Stuff that matters.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by hythloday on Thursday August 30, 2012 @01:22PM (#4455685)
To an extent, they're forced to - when all you have are dynamic arrays and hashtables (I'm thinking of python here), it's hard to go very far wrong. (Isn't it? Am I being naive?)
Re:Why should I have written ZeroMQ in C, not C++ (part II) by Someone on Thursday August 30, 2012 @02:39PM (#4456089)
Naive? I do not know, but your logic surely is :-)

Consider the similar "if you have only one kind of string, it's hard to go wrong". If you need Unicode, but your only type of string is ISO-8859-1, or if you need to cramp many strings in memory, but your only string class uses UTF-32 internally, it's almost unavoidable that you go wrong.

The advantage of having only few data structures is that the developers of the system have only few places where they have to spend effort on optimization. So if, like Python, your platform is popular, chances are that those few basic structures have been optimized to death.

That does not necessarily make them optimal for every use case, though. The big advantage of C++ is that, if the need arises, you can (see below) make a special-case data structure that beats even the most optimized general-purpose one.

Of course, that 'can' is relative. It is really hard to make a robust special-case data structure.

Re:Why should I have written ZeroMQ in C, not C++ (part II) by JoachimSchipper on Thursday August 30, 2012 @02:25PM (#4456017)
From yesterday's bug hunting session: sets (okay, not exactly hash tables) are not ordered data types, so do not use a set for intermediate values when order matters. (My fault - I'm just pointing out that it's not that hard to get Python wrong either.)
Re:Why should I have written ZeroMQ in C, not C++ (part II) by dkersten on Thursday August 30, 2012 @05:00PM (#4456784)
Well, sets are the canonical unordered collection, after all.
Re:Why should I have written ZeroMQ in C, not C++ (part II) by btilly on Thursday August 30, 2012 @04:18PM (#4456531)
It is rather hard (though I believe not impossible) to find a use case where dynamic arrays and hashtables are not within a constant factor of the best possible data structure.

Admittedly, that constant may be fairly large.