I've been experimenting with using Objective-C (specifically the GNU runtime, I'm not using GNUStep or anything like that) to extend C with objects. So far its going well - it works well and I really like the syntax, however from what I've been reading there is a performance penalty to using Objective-C objects.
I'm not normally one to optimise prematurely but I'm developing a game and so performance will eventually end up being fairly critical - I'd like to know what I'm getting myself into! Several people have suggested that I will be fine using Objective-C in a game as long as my innermost loops are written in standard C, however the question is finding the point where I should make that switch.
So my question is twofold:
- What exactly will incur a performance penalty? (so I know what I should avoid)
- Roughly how significant is this performance penalty? (so I can guestimate in advance which bits of my game will need to be written in C anyway)
My guess is that calling methods on an Objective-C object will incurr a penalty, but I wasn't sure what else would - does de-referencing an Objective-C object incurr a similar penalty?
int a = myobj->a;
How about using a try-catch-finally
- will this incur a performance penalty in situations where there is no exception thrown?
I realise that to a certain extent I could figure most of this out myself using benchmarks, but I'm relatively new to this and I was hoping for a deeper understanting of how Objective-C works and the nature of any performance penalties.
I'm not interested in C++ for the moment, I'm just experimenting with Objective-C.