crazy-mad geeky!
Wow. I don’t know how I missed it all these years, but you can mix Objective-C and C++ in OS X’s gcc with something approaching wild abandon. Not true wild abandon:Â you basically get two runtimes each doing their own thing, and the objects of each can’t inter-breed or anything weird like that. But you can mix the two dialects freely in expressions:
[ mInfoString appendFormat:@"Camera Location: ( %f, %f, %f )", mLoc.getX(), mLoc.getY(), mLoc.getZ() ];
Crazy!
In the past couple of days I’ve resurrected some Powerplant C++ 3D game-engine code I wrote as an undergrad. Seriously old-school. It’s now living in a Cocoa app. Yay, fun. =)
I’m doing this because, odd as it sounds, it may become part of my thesis. In architecture.
Now that I’m finally starting to learn Obj-C and Cocoa … so far I have mixed feelings. I don’t like the number of things done by convention, as opposed to compiler-assisted or -enforced. Constructors and destructors, for instance: I think the compiler is your friend and you should let it do as much work as possible, including running destructor code on automatic objects as the stack unwinds. Hard to do that when everything lives on the heap*. Also, strict type-checking is a good thing; I don’t see myself ever being convinced to the contrary. I’m also not yet convinced that Obj-C’s memory management conventions get me anything over C++. Seems like it’s less simple, not more.
But it’s early on and I’m still learning it, and I’m quite comfy with C++, so maybe I just don’t see the beauty of Obj-C yet. I am kind of digging the message-passing syntax. But that’s not particularly huge.
* Maybe that’s what autorelease does? If so, that’s an extra thing for me to remember to do, by convention. Well, obviously I have more to learn.