exceptions impact
-
Hi,
welche vorteile/nachteile gibt es beim benutzen von exceptions?
wie verhalten sich exceptions bezueglich performance?
warum verwendet google keine exceptions in deren code?
-
Da würde ich vorschlagen, dass du dich mit Hilfe eines bekannten Suchdienstes auf die Suche machst und uns das hier präsentierst.
-
theta schrieb:
Da würde ich vorschlagen, dass du dich mit Hilfe eines bekannten Suchdienstes auf die Suche machst und uns das hier präsentierst.
-
Was die Leute bei Google sich dabei gedacht haben, kannst du sehen, wenn du hier auf das Dreieck links neben der Regel klickst.
On their face, the benefits of using exceptions outweigh the costs, especially in new projects. However, for existing code, the introduction of exceptions has implications on all dependent code. If exceptions can be propagated beyond a new project, it also becomes problematic to integrate the new project into existing exception-free code. Because most existing C++ code at Google is not prepared to deal with exceptions, it is comparatively difficult to adopt new code that generates exceptions.
Given that Google's existing code is not exception-tolerant, the costs of using exceptions are somewhat greater than the costs in a new project. The conversion process would be slow and error-prone. We don't believe that the available alternatives to exceptions, such as error codes and assertions, introduce a significant burden.
Our advice against using exceptions is not predicated on philosophical or moral grounds, but practical ones. Because we'd like to use our open-source projects at Google and it's difficult to do so if those projects use exceptions, we need to advise against exceptions in Google open-source projects as well. Things would probably be different if we had to do it all over again from scratch.
mit anderen Worten: Die haben nen Arsch voll furchtbaren Legacy-Codes, der nicht exceptionsicher ist und wollen den mit allem neuen Code verheiraten können.
Wie zukunftsträchtig das ist, sei mal dahingestellt, zumal es einige andere, dämliche Regeln forciert. Zum Beispiel macht
Doing Work in Constructors
Avoid doing complex initialization in constructors (in particular, initialization that can fail or that requires virtual method calls).
zwar Sinn, wenn man keine Exceptions benutzt, weil man aus einem Konstruktor ohne sie keinen Fehlerzustand bekanntgeben kann, führt aber zu der unangenehmen ituation, dass man nach der Konstruktion noch kein benutzbares Objekt hat. Und wie sie mit der Methode die Standardbibliothek benutzen wollen, ist auch nicht ganz klar. Soll man alle Standardfunktionen vermeiden, die Exceptions werfen könnten? Überall new(std::nothrow), kein vec.at? Mir scheint, da wurde auf Sand gebaut.
-
There is an exception to this rule (no pun intended) for Windows code.
-
Naja, wenigstens sind sie sich darüber im Klaren was sie gemacht haben, und stellen entsprechende Regeln auf, damit der alte Code nicht "bricht".
-
wie verhalten sich exceptions bezueglich performance?
Nutzt du SJLJ, dann muss bei jedem Betreten eines
try
-Blockssetjmp
aufgerufen werden, um die Register im Jump-Buffer zu speichern. Damit hast du einen Performance-Verlust, sogar wenn keine Exceptions geworfen werden. Dwarf hingegen macht sowas zur Compile-Zeit, und stopft alles in eine Tabelle.
GCC unterstuetzt AFAIR beide.Dann muss noch das Exception-Objekt erstellt werden, und das Stackunwinding wird durchgefuehrt.