4 ms·
Yes, but no. Yes, as in of course you are correct. However, this is an argument that Bjarne often uses in the context of C++, and it drives me a bit batty. Fo
by RogerL 13y ago
Yes, but no.
Yes, as in of course you are correct.
However, this is an argument that Bjarne often uses in the context of C++, and it drives me a bit batty. For example, he'll wax eloquent on how it is fine that there is no multidimensional array type built into the language, because look how easy it is to write one yourself, or use one somebody else wrote.
And, at the first approximation, that is surely true. Heck, I'm taking time out to post this from working on a Kalman Filter class I wrote that uses a hand coded multidimensional array class.
But, the problem is is that there are thousands of string libraries out there, and thousands of multidimensional arrays, and so on. And they don't play nicely with each other.
Heck, we use char, std::string, CString, and QString all in the same project. You can guess the evolution - a bunch of old library code written 10 years ago who didn't trust/like the new-fangled std::string stuff. External library code written in C. Then code written in modern C++ with an aim to be portable (std::string). Then some MFC UI code, and more code written by MFC people that didn't care about strewing that dependency in places where it didn't belong. And now we are in Qt, and I have to really clamp down on the code reviews to keep QString from straying beyond the UI components. Ugh.
Hey, I love C, and this is not a rant against the language. C strings have their place. I can't tell you how many times I've written code along the lines of:
char* c = some_data();
c += header_size;
name = extract (c, ',');
You get the idea. At one time that was the state of the art way to do string processing without the cost of a lot of extra creation/deletion. You just use pointer arithmetic, move along a data source, scraping it as you go.
But these days we aren't so interested in that kind of scraping, and are far more interested in higher level problems. And we have no standard to fall back on, in C. Sure, I can elect to use a third party library, under the almost never to be satisfied requirement that every line in our project is written in house, or that every third party library either uses the library I chose, or that it can inter-operate with it seamlessly. Frankly, I've never been in a situation where either of those held. So we end up either reverting to the mean (c strings), or making endless conversion calls to switch from one form to another.