Dear C++ library writer,
-
If your library forces me to use
new
all over, I will hate you. -
If your library has types with bogus values, I will hate you.
-
If the documentation for your library gets the terminology of its own domain wrong, I will hate you.
-
If I say "My God, it's full of stars!" when I see the function signatures in your library, I will hate you.
-
If your library uses
#define
instead ofconst
orinline
, I will hate you. -
If your library has a base class of everything, I will hate you.
-
If your library has singletons, I will hate you.
-
If you think you can use a tool to automatically translate a library from Java, I will hate you.
-
If the classes in your library have such clear responsibilities that you call them "managers", I will hate you.
-
If your library does not play nice with the standard library, I will hate you.
-
If functions in your library return error codes instead of throwing exceptions, I will hate you.
-
If your library has public members that are designed to be used only from internal code, I will hate you.
-
If your library makes use of the global namespace, I will hate you.
-
If your library has types traits that don't play nice with SFINAE, I will hate you.
Performance is not an argument against exceptions, since they are faster then error-codes when not thrown (which should be almost all of the time); real-time behavior is. So: If the library is for controlling a plane or space-ship, yes, exceptions should be avoided.
Often when exceptions aren't used however, the reasons are clearly not as good. GUI-libraries for example should really use exceptions for their errors.