stdio performance in tango, stdlib, and perl
Walter Bright
newshound at digitalmars.com
Sat Mar 24 11:56:08 PDT 2007
James Dennett wrote:
> Walter Bright wrote:
>> But still, there are one or two that repeat the conventional (and wrong)
>> wisdom about garbage collection. Such conventional wisdom is much more
>> common among the general population of C++ programmers.
> Which "wrong" assertions are those?
gc is a crutch for lazy/sloppy/less capable programmers, gc isn't for
mission critical industrial apps, gc is for academic unusable languages,
etc.
>>> I think there is a tendency to assume that APIs and languages which
>>> have (A) been around a long time and
>>> (B) been used by millions of people
>>> will probably be close to optimal. It just makes sense that that
>>> would be the case. Unfortunately, it's all too often just not true.
>> I just find it strange that C++, a language meant for building speedy
>> applications, would incorporate iostreams, which is slow, not thread
>> safe, and not exception safe.
>
> I'm intrigued by your claim that IOStreams is not thread-safe;
> the IOStreams framework is thread-safe in the same way that
> the STL is thread-safe. The one minor difference is that
> IOStreams exposes some global variables, which is unfortunate
> as they can easily be used in inappropriate ways in a
> multi-threaded environment.
Note the reliance here on global state that is neither thread nor
exception safe:
std::ios_base::fmtflags flags_save = std::cout.flags();
std::cout << 123 << '|' << std::left << std::setw(8) << 456 << "|" <<
789 << std::endl;
std::cout.flags(flags_save);
> Then again, that is unsurprising
> as C++ does not yet officially incorporate support for
> multi-threading.
That's not an excuse, as 1) multithreading was common long before C++98
was written and 2) multithreading and exception safety was thought about
and accounted for in much of the rest of the library design, despite
threading not being official.
> Is there something deeper in IOStreams that
> you consider to be thread-unsafe, or is it just the matter of
> its global variables?
All I can do is point to the example above.
More information about the Digitalmars-d
mailing list