Why does QT use so few exceptions?
-
wrote on 6 Oct 2010, 08:39 last edited by
Hi,
I am developing Java programs since 3 years, so I very often work with exceptions. I wonder why QT does not use them as oftens. It seems that they are used as less as possible. Can somebody explain, why? -
wrote on 6 Oct 2010, 10:16 last edited by
When Qt was started exceptions were not available for all the compilers that needed to be supported by Qt. Today we are trying to keep the APIs consistent, so modules that have a history of not using exceptions will generally not get new code using exceptions added.
You will notice exceptions are used in some of the new modules of Qt.
-
wrote on 6 Oct 2010, 11:37 last edited by
Tobias, does it mean that some day (version of Qt like 6.10) we will have exception-style error handling in Qt, not error()-methods?
-
wrote on 6 Oct 2010, 14:22 last edited by
Denis: For consistency we should not mix error handling styles in modules, so I can not see this happen without causing a mayor version number change (since the non-exception style would need to get removed which will break source compatibility).
But this is just my opinion: I am not aware of any plans for Qt 5 or later.
-
wrote on 6 Oct 2010, 18:58 last edited by
[quote author="Tobias Hunger" date="1286374926"]
But this is just my opinion: I am not aware of any plans for Qt 5 or later.[/quote]NOOOOOOO!!! =P
-
wrote on 6 Oct 2010, 19:55 last edited by
danilocesar: What was that NOOOOO about?
-
wrote on 6 Oct 2010, 20:09 last edited by
It's a good place to change major architecture decisions without harm current devs.
From a simplistic point of view (without thinking about continuous improvement of current apps, kde, nokia, market, etc), who doesn't want Qt 5? :) -
wrote on 6 Oct 2010, 20:25 last edited by
[quote author="Tobias Hunger" date="1286394948"]danilocesar: What was that NOOOOO about?[/quote]
Just read this sentence and forget about the context of this thread:
"I am not aware of any plans for Qt 5 or later."
-
wrote on 6 Oct 2010, 20:39 last edited by
MTK358: I do not know of any plans, that does not mean that nobody else is doing planning;-)
-
wrote on 7 Oct 2010, 06:32 last edited by
To come back to the original question: Is there a technical reason, not to use exception to handle errors? I understood, that the reason was historically, so it's basically a good idea to use exceptions in my own programs.
-
wrote on 7 Oct 2010, 18:30 last edited by
I don't think there would be a lot of places where Qt would really benefit from exceptions, but hey, I might be missing something :).
-
wrote on 17 Oct 2010, 09:31 last edited by
s.frings: Yes, there is no reason not to use exceptions in your own programs. I do not know whether it is a good idea for consistency reasons: I prefer not having to switch between exception/non-exception code, but that is just a matter of taste.
-
wrote on 22 Oct 2010, 15:59 last edited by
What about QSqlError ?
I find it annoying calling lastError() every time I execute a SQL query. I can't think of a better place to use exceptions instead of error codes. Not to mention that exceptions are thread-safe. -
wrote on 22 Oct 2010, 18:05 last edited by
What are the advantages of Exceptions?
-
wrote on 22 Oct 2010, 18:44 last edited by
Some of them are explained "here":http://www.parashift.com/c++-faq-lite/exceptions.html
And keep in mind:
there is NO one size fits all! Exceptions might work wel for one case, but not for the other. -
wrote on 22 Oct 2010, 18:49 last edited by
I hope Qt starts to use exceptions soon!
-
wrote on 22 Oct 2010, 18:54 last edited by
You'll have to wait at least until Qt 5 comes around.
All releases of the Qt 4 series will stay source and binary compatible. Switching to using exceptions is a far too big change. Maybe it will come sometimes, but don't expect anything. There aren't even rumors about a timeline of Qt 5, even less abut exceptions...