On Wed, Jun 26, 2013 at 11:47:32PM +0200, Paulo Pinto wrote: > Am 26.06.2013 20:52, schrieb H. S. Teoh: [...] > >None of my C++ code uses iostream. I still find stdio.h more > >comfortable to use, in spite of its many problems. One of the most > >annoying features of iostream is the abuse of operator<< and > >operator>> for I/O. Format strings are an ingenious idea sorely > >lacking in the iostream department (though admittedly the way it was > >implemented in stdio is rather unsafe, due to the inability of C to > >do many compile-time checks). > > I have been an adept of iostreams since day one and never understood > why people complain so much about them or the operator<< and > operator>> for that matter.
They're ugly, that's why. :) And misleading to anyone familiar with bit operators. But that's beside the point. The main problem is that format strings are inadequately replaced by operator<< and its ilk; C++ tried to get around them by introducing the concept of manipulators and whatnot, but that only increased the ugliness of it all. Plus, it made a string of <<'s stateful, (if the previous line sends a manipulator to cout, then subsequent <<'s are subtly modified from their usual behaviour) making it harder to read. D's writefln is far superior to C's stdio and C++'s iostream, in any case. > But I try to keep my C++ code clean from C'isms anyway. [...] I tried doing that once. It was a rather painful experience. That's the problem with C++: it started out as being C + classes, but then wanted really badly to assume its own identity, so it accumulated a whole bunch of other stuff, but then it never really cut its ties with C, and the old C + classes heritage lives on. As a result, its OO system leaves a lot to be desired when compared with, say, Java, but using it for just C + classes seems underwhelming when there's so much more to the language than just that. So you end up in this limbo where it's more than C + classes, but doesn't quite make it to the level of real OO like Java, and lots of hacks and ugly corner cases creep in to try to hold the tower of cards together. Trying to be free of C'isms only exposed the flaws of C++'s OO system even more. I found that writing C + classes is still the least painful way to use C++. Fortunately, there's D to turn to. ;-) T -- Too many people have open minds but closed eyes.