I'm a professional C programmer and a hobbyist Obj-C programmer (OS X). Recently I've been tempted to expand into C++, because of its very rich syntax.
So far coding I haven't dealt much with exceptions. Objective-C has them, but Apple's policy is quite strict:
Important You should reserve the use of exceptions for programming or unexpected runtime errors such as out-of-bounds collection access, attempts to mutate immutable objects, sending an invalid message, and losing the connection to the window server.
C++ seems to prefer using exceptions more often. For example the wikipedia example on RAII throws an exception if a file can't be opened. Objective-C would
return nil with an error sent by a out param. Notably, it seems std::ofstream can be set either way.
I haven't found anyone doing an objective study for C++. It seems to me that since pointers are rare, I'd have to go with internal error flags if I choose to avoid exceptions. Will it be too much bother to handle, or will it perhaps work even better than exceptions? A comparison of both cases would be the best answer.
Edit: Though not completely relevant, I probably should clarify what
nil is. Technically it's the same as
NULL, but the thing is, it's ok to send a message to
nil. So you can do something like
NSError *err = nil; id obj = [NSFileHandle fileHandleForReadingFromURL:myurl error:&err]; [obj retain];
even if the first call returned
nil. And as you never do
*obj in Obj-C, there's no risk of a NULL pointer dereference.