# Objective C and C++ for Game Development

I'm trying to figure out which language I should begin learning. I've only been programming for about 6 months, with languages like PHP, Java, and C#. I want to learn how to dev games, and while I know in most cases the answer to this would be through C++ (at least, I would think), though I'm still curious about what Objective C can offer in the sense of long term benefit.

It seems like there's a chance that Objective-C may actually become more popular than C++ in a few years, and for all I know, it may become the de facto standard development language for games. Still, despite all of this, I really don't know anything, and this is all speculation.

Both languages seem very interesting, and obviously can pull a lot of out of themselves.

What do you think?

Note: despite what some might say, I really don't want to end up using prebuilt engines, and would rather just learn how to make my own. I'm well aware that it takes a lot more time, but I'm quite ok with that.

• I hardly imagine Objective-C becoming more popular than C++ outside the "Mac world". – Valkea Jun 22 '11 at 14:58
• I removed your edit since it contained a subsequent question that would be better posted as an entirely new question. Having multiple-questions-in-one is generally undesirable here because it makes the answers/discussion harder to follow. – user1430 Jun 22 '11 at 15:05
• Also welcome to the site! – user1430 Jun 22 '11 at 15:12
• Gotcha, I'll keep that in mind from now on. – blissfreak Jun 22 '11 at 15:24

I want to learn how to dev games, and while I know in most cases the answer to this would be through C++ (at least, I would think),

Actually, while C++ is an important language for anyone aspiring to enter the field professional, it is by no means the language you have to learn to make games and, in fact, makes for a rather poor first language (primarily due to its complexity, the wealth of incorrect/poor information on the language out there, and most important its cultural penchant for assuming the programmer is right, which is bad for a neophyte).

It seems like there's a chance that Objective-C may actually become more popular than C++ in a few years, and for all I know, it may become the de facto standard development language for games. Still, despite all of this, I really don't know anything, and this is all speculation.

Something will replace C++ eventually, as C++ has by and large supplanted C, which has by and large replaced machine-specific assembly. That said, it's very hard to gauge what will replace C++ and mostly a thought experiment -- for practical concerns, it doesn't matter what language we all eventually move on to.

It's fair to surmise that the popularity of the iOS platform might help usher in a new era for Objective C, one where it's not considered some unusual warty distant cousin of C++. But in practice one can write iOS games with a bare minimum of Objective C bootstrap code (doing the rest in C++), and Objective C itself doesn't offer enough modern advances to make it otherwise more attractive, so I doubt it will replace C++ ever.

Note: despite what some might say, I really don't want to end up using prebuilt engines, and would rather just learn how to make my own. I'm well aware that it takes a lot more time, but I'm quite ok with that.

Do you realize that using pre-built technologies is (1) essentially inevitable (you'll be using a pre-built runtime on a pre-built OS for example) and (2) orthogonal to the issue of which language you use?

It's fine to build things yourself for learning purposes, but don't let "not invented here" syndrome get you in its claws. Once it has you, it's hard to get out, and it's very easy for a new programmer to get snatched up. Resist the temptation, you will be a better developer for it in the long run.

So all that ancillary stuff being said, to answer your real question:

It doesn't matter which language you pick. My personal recommendation for people who want to get into game development and don't already know any programming languages is C# or Python. If you already know a language, use that language (it sounds like this is where you fit; if you know some C# already, I'd say continue using that). If you really can't decide, flip a coin. Between C++ and Objective C I'd say go with C++, since I think the available tools are more mature (especially on the Windows platform -- Xcode is decent if you are on a Mac, but it's no Visual Studio).

A good programmer will know many languages and, similarly, the more languages a programmer knows the easier it is for her to pick up more. So you should never be focused on trying to predict the motion of the industry so as to study the "right" language. Instead, pick something, learn it, make some games, and move on to new languages as the time comes. You will never be wasting your time doing so.

• Thank you, your response was truly a blessing. As far as the "not invented here" syndrome: are you referring to when a programmer has the urge to just code everything out, regardless of whether or not it's already been done? The mean reason why I want to build a game engine is partly because of that, but also because I really want to learn how to code something complex, even if it sucks in the end. I'll probably go with C/C++. I've read C code before, and haven't had much problem understanding it, so I think I'll be ok in that regards. – blissfreak Jun 22 '11 at 15:07
• On the writing an engine subject, I've written this article which contains my thoughts. The tl;dr version is that you should build your engine by writing multiple games and refactoring out/reusing the appropriate aspects of each. That's how you build a good engine, not by following some "engine tutorial" (most of which are complete drivel, so beware when searching the internet). – user1430 Jun 22 '11 at 15:10
• Reading right now... – blissfreak Jun 22 '11 at 15:16
• Ok, You've got me. I'll write my own games first, and then worry about devving an engine. It makes sense that things will go more smoother that way, I guess. Either way, thanks. I appreciate it. – blissfreak Jun 22 '11 at 15:23
• Good luck! If you'd like to talk further you can usually find good conversation in the chat – user1430 Jun 22 '11 at 15:31

From my perspective, Objective-C is mainly used to develop for OS X and iOS. And even there, a lot of people tend to use C++ because of portability. Looking at a language comparison over at Ohloh, I can't really see much of a trend that Objective-C will replace C++ in the near future.

Also have a look at this question (Objective-C or C++ for iOS?).

I personally like Objective-C, but C++ is far more widespread and very portable. You'll also find tons of resources and libraries about/for C++. If you want to develop specifically for iOS or Mac OS X, you could consider Objective-C, but for all other cases I strongly reccomend C++.

• C++ portability is a bit of an oxymoron 8) C++ tends to be the lowest common denominator for cross-platform development. +1 for liking Objective-C. – Daniel Blezek Jun 22 '11 at 17:28

Here are a couple of other posts that are related to your question:

Is C++ "still" preferred in game development?

What are the most commonly used programming languages?

Am I hurting myself by not knowing C++ for game design?

Also, this isn't terribly relevant, but I thought it was interesting: Google's language performance comparison

Where raw performance is concerned, C++ as a language has an advantage over Objective-C as it favors compile-time over runtime (static dispatch, templates, C++ 0x constexpr). It is doubtful that Objective-C will ever replace C++ as the lingua france of cutting-edge game development.

However, more dynamic languages like Objective-C are generally superior where ease of implementation is concerned. But no one forces you to implement your game in a single language, and it's common to embed the runtime for an even higher-level language like Lua into C++ game engines.

This isn't to say that Objective-C is a bad language for game development - its rather unique combination of raw performance and dynamism definitely fits the problem domain, and thanks to Apple it has recently gained some popularity - but it's not a silver bullet: There are better choices for the highest and the low end of the performance spectrum.