[...]
Your statements, name calling etc. sound like goading, but then, with so
much of it and so forcefully expressed I'm now not sure that you don't
really think you mean what you write.
There is a fine line between, on the one hand, good-natured bantering,
exaggeration and the technique of hyperbole, and, on the other hand,
being ungood, and I'm sorry to tell you that you have crossed that line
and some other lines repeatedly and by miles in this thread.
Yes. I realised that I'd gotten a bit out of hand shortly after
sending that last posting. I apologize. I don't know why, but
there's something about the way you express yourself which gets
to me. It's personal---I know other people who have no problem
with you, but do have problems with people who don't get on my
nerves. And I can't find any concrete reason why I react this
way. I know that you are more than competent---you've proved it
often enough in the past, and that there's usually something
behind your opinion, even when we disagree.
What's upsetting me is your attacks on iostream. I know that
you don't like them. Fine, but... your complaints seem to be a
haphazard mixture at several different levels, which makes it
difficult to respond reasonably. And you don't suggest an
alternative: several of your complaints (including some of the
most justified) are a direct result of the semantics being based
on stdio, so presumably, you don't like that either. My problem
is first and foremost, what do you teach beginners in C++---I
haven't found anything better than iostream to date. And from
an engineering point of view, I don't find the minor flaws of
iostream important enough to justify writing an alternative.
I don't argue that iostream is perfect. Even Jerry Schwartz'
initial design had some minor flaws (e.g. the naming
conventions, and error reporting in general), and in this case,
the ISO committee certainly didn't help things. On the other
hand, I do think that it is fundamentally a very original and
very effective design---I would recommend the original design,
for example, as an example of exactly how a good design chooses
between virtual functions (in streambuf) and function
overloading (the << and >> operators) to allow different types
of extendibility.
So on one hand, I'm interested in hearing what you'd propose
which meet the design criteria: extendability to user defined
sinks and sources, extendability to user defined types, and a
possibility for users to define their own "format specifiers"
(manipulators, in iostream---I don't know what in other designs,
because iostream is the only design I've seen which supports
it). stdio obviously fails on all three counts, in addition to
being fundamentally unsafe. The only other alternatives I'm
aware of are boost::format and GB_Format/Gabi::Format. Both of
which are strongly based on iostream.
With regards to some specific complaints you mentioned (from
memory, I don't have your original posting handy):
Two phase initialization:
I'm not really sure what you're complaining about here. A
priori, the reason two phase initialization isn't a good
thing in general is that it requires client code to be able
to deal with an invalid object. But that reason doesn't
apply to IO---user code must always be able to deal with an
invalid object (regardless of the design), because it is the
nature of IO that once valid objects become invalid during
use. After fopen, if I receive a non-null FILE*, I know
that I have a valid open file, but as soon as I've executed
the first operation on it, I'm back in the same situation as
I am with iostream. It does make things more difficult for
the client code, but it is a fact of life with IO; you can't
get around it.
Undefined behavior when inputting numeric values:
This is, of course, inherited from stdio, and also affects
boost::format. (But not GB_Format! I reimplemented all of
the numeric conversion functions myself. It's not something
I'd recommend---definitly too much work for too little
benefit.) From a quality of implementation point of view, I
expect that all implementations in fact handle overflow
correctly---the ones I regularly use do. If yours doesn't,
then you should complain loudly to the vendor.
Which is, of course, no excuse for such laxity in the
standard. I've just written up a proposal to fix it, which
I will submit as soon as I get a document number to do so.
(The deadline for the next mailing is 9AM Monday morning,
PST. Given the time differences between here and there,
there's even a good chance that I get it in that mailing.)
The fact that there is persistent state:
I'm not sure that you expressed it like that, but if I
remember correctly, you didn't like the idea of the
formatting options being handled by class state. From a
purely design point of view, I agree, but I've not seen an
alternative which avoids this problem, and meets the other
design requirements. Until proven otherwise, I'll consider
it a necessary evil.
Performance:
That is, of course, very implementation dependent. The
modifications made by the standard committee didn't help
anything here. Still, it's possible to implement iostream
so that it is even faster than stdio---Dietmar Kuehl had a
proof of concept implementation at one time, I believe.
In the meantime, I've never had to renounce using iostream
because of performance concerns. I suspect that this is
fairly general, and that it accounts why even the best best
current implementations (Dinkumware, g++, etc.) haven't made
the effort of improving performance, e.g. by using Dietmar's
ideas.
And I'll grant you the criticisms concerning error detection and
recovery---it's definitly iostream's weak point. That, and the
fact that the function names sometimes take some getting used
to, to put it mildly. (IMHO, the most serious flaw in the
design is that eofbit does double duty---internally, to remember
that an EOF has been seen from the streambuf, and externally, to
tell the user why the last request failed. These really should
be separated.)
Anyway, my challenge remains: what do you recommend to
beginners, and why? How is it better?
(And I am sorry about the previous posting. Every time we
manage to discuss something reasonably, it turns out to be very
enriching. Hopefully, starting this discussion over...)