Question

I see a lot of debate going back and forth on which language to use to develop real-time 3D games, and the general consensus is that C or C++ are the only languages that can offer suitable performance for high-end, system-intensive 3D games. I see a lot of people saying C#, Java or Python are too slow, particularly because of garbage collection. How about Objective C? Does Objective C have automatic garbage collection? What besides Automatic Garbage Collection make a language 'too slow' or unsuited for 3D games?

This question is probably more of a 'thought experiment' since I doubt I'll ever develop a game that is so resource heavy that these questions need to be addressed, but being a programmer, I'm inexplicably obsessed with performance, so I'd still like to know just for my own jollies.

Was it helpful?

Solution

Objective-C 2.0 has garbage collection available on Mac OS X 10.5, but it is optional -- you can still compile Objective-C apps without garbage collection if you so choose. On other platforms (iPhone, Mac OS X pre-10.5, and anything else), there is no garbage collection, and you have to manually manage your memory.

Objective-C is a strict superset of C, so you can code plain C in Objective-C if you want. Hence, there's no reason not to use Objective-C for games that wouldn't also apply to using C. You can use the extra features Objective-C provides as much or as little as you want.

OTHER TIPS

The only real slowdown with Objective-C itself would be the messaging mechanism—and even then, it's usually components of the Cocoa framework that would slow things down. Objective-C's message sending doesn't really hurt performance that much.

Anyways, for most games, the majority of the performance bottlenecks will come from graphics code: if you delegate graphics stuff to OpenGL, which is ridiculously fast, then there really should be no problem with using Objective-C for games. The only other place where I can see Objective-C or Cocoa providing bottlenecks would be for intensive physics code—and that should probably be written in pure C/C++ anyways. Everything else, though, shouldn't really matter that much.

To be honest, I'd wager that the majority of OS X games nowadays are written in Objective-C using the Cocoa frameworks, with the performance-sensitive code written in pure C/C++ (and with graphics code utilizing OpenGL).

I'm also interested in the topic and i found this http://wiki.gnustep.org/index.php/3DKit

It looks quite dead but now with clang/llvm 2.9 many of the goodies of Objective-C 2 are available on linux and could be interesting to have 3D API.

Objective-C does not have automatic garbage collection. Java has various methods of garbage collection and some of them are designed to be compatible with games by occurring incrementally at regular intervals. I would be surprised if C# or anything else which also had garbage collection didn't have multiple methods to choose from, some of which are compatible with games.

The only thing off the top of my head that would might make a game unsuitable for 3D games would be if it were interpreted and particularly slow in its implementation. That's not a characteristic of anything you listed above.

P.S. To address your original question, I'm pretty sure anyone who has an iPod Touch or iPhone will be able to tell you that Objective-C is definitely up to 3D games :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top