[Qt-interest] Qt and C++ exceptions
Paul Floyd
paulf at free.fr
Sun May 24 21:36:32 CEST 2009
Piotr Dobrogost wrote:
> Paul Floyd wrote:
>>Maxim Egorov wrote:
>>
>>>Why qt does not use exceptions? This is a very powerful mechanism which allows to significantly simplify the processing of errors and create more reliable software. I have read http://qt.gitorious.org/qt/pages/CodingConventions and was amazed. I think this is a very strange decision. It seems to me that so hard to find C + + compiler does not support exceptions. So I think it would be wise to consider support for exceptions to be one of the most important tasks.
>>
>>Two things
>>a) When Qt was originally developed, not all compilers supported
>>exceptions, so the core components were written using relatively
>>unsophisticated C++ (no exceptions, no fancy templates). Other than
>>easing portability, in my experience exceptions and fancy templates
>>usually mean poor performance and code bloat (and long compile times).
> Poor performance due to exceptions?
> Good implementations have zero overhead if exceptions are not thrown.
I don't think that exceptions cost too much in performance, unless misused.
> Code bloat?
> Templates are the best way to generate as little code as it's possible
> given a spectrum of used types. Try to write it better by hand...
Here I don't agree. Template code can be lean and/or fast (e.g., the
likes of blitz and loki) but it can also be a dog (like boost::spirit or
boost::lambda). I'd hate to see Qt become like boost. But this is
wandering a bit off the original subject, which was about the use of
exceptions.
>>b) Exceptions are difficult (read Herb Sutter for gory details). I'm not
>
> They are because they are part of programming :)
> Thousands of manual checks trying to cover tens of thousands of code
> paths are even more difficult...
>>sure that I'd want to use a library that forced me to try to write
>>exception safe code.
> That's not a library that should force you but drive to create robust
> software.
Google "c++ exceptions robust" and click on the first hit for a classic
on the subject.
A+
Paul
--
Paul Floyd http://paulf.free.fr
More information about the Qt-interest-old
mailing list