Objective C or C++ ...& OpenGL ES

Discussion in 'Public Game Developers Forum' started by pchukwura, Sep 18, 2010.

  1. pchukwura

    pchukwura Well-Known Member

    Sep 15, 2010
    184
    0
    0
    Co-Founder/Software Engineer
    Atlanta
    So i've been learning Open GL ES for the past couple of months, and the book i've been following uses Objective C (which i'm quite proficient in). However, I've looked at some other books that typically use C++(which i'm decent in), and read a statement by the Pocket God people of them switching from Objective C to C++

    I just wanted to know what do you guys prefer or what is recommended when developing iOS games with Open GL ES?

    I've been leaning more toward C++ as of late as it seems like the language of choice my game developers and it's a tad lower level than Objective C, even though i'm more familiar with ObjC.

    Thanks all!
     
  2. NickFalk

    NickFalk Well-Known Member

    If you're already familiar with Objective-C and don't plan to develop for other platforms there's no reason to switch. It will certainly make it easier for you to get stuff "for free" through Apple's API's.

    If however you'd like to move your projects to other platforms as well it might make sense to go down the C++ route as it has a much wider support...
     
  3. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    OpenGL is of course a C API which means you can use it from either. Personally, I'd always choose C++ and keep the use of Objective C to a minimum.This is vital to me because portability and being able to work with programmers who know even less Objective C than I do is important. I know at least ten times as many C++ programmers as objective C.
     
  4. pchukwura

    pchukwura Well-Known Member

    Sep 15, 2010
    184
    0
    0
    Co-Founder/Software Engineer
    Atlanta
    Well it's not so much switching, as I have not actually started on a particular project. And I do plan on moving my projects to other platforms (if they become popular enough) so that was one thing in my head.
     
  5. pchukwura

    pchukwura Well-Known Member

    Sep 15, 2010
    184
    0
    0
    Co-Founder/Software Engineer
    Atlanta
    Ya i was going to take some examples I had and simply convert them to C++ to get more familiar...with the exception of the EAGLView and ...AppDelegate files of course.

    Have you noticed a performance difference on using C++ vs Obj C at all?
     
  6. FlagellumDei

    FlagellumDei Well-Known Member

    May 14, 2009
    215
    0
    16
    Programmer
    I prefer C++ anytime...

    I hate when companies like Apple or Microsoft are creating a new programming language just to be different.
     
  7. NickFalk

    NickFalk Well-Known Member

    I think you should look into the history of Objective-C as your statement doesn't make much sense... ;-)
     
  8. CommanderData

    CommanderData Well-Known Member
    Patreon Indie

    Microsoft is guilty of this, but not Apple... Objective C was invented almost 30 years ago, and was licensed by NeXT in the late 1980s. The reason it's kicking around at Apple now is because OSX (and now iOS) is heavily based on code from NeXT that Apple integrated when acquiring them in the 1990s.

    Anyway, if the OP is looking for quick results, and is more familiar with Objective C then simply use it. Don't worry about speed issues until you run into them (no premature optimization)! Don't worry about cross platform compatibility until you prove you're able to finish a game that is awesome enough that people on other platforms want it. ;)

    Edit- NickFalk beat me by 1 minute on the Obj C comments!
     
  9. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    I've used C++ for 12 years and only written a few hundred lines of Objective C ever so i'm the wrong person to ask.

    My iPhone programming has been in a rather cut down version of C++, lots of statically defined classes, very few allocations at load time, none at all while a level is running. It's a refreshing change from some of the large titles I've worked on and, I think, avoids lots of those memory headaches that are supposed to make C++ 'harder' than objective C.
     
  10. TrueAxis

    TrueAxis Well-Known Member

    Sep 7, 2009
    610
    0
    0
    We use C++ because of portability. Writing everything in objective C is a bad idea as you may want to port the game to something like Android if the game is received well and you start thinking of other markets.
     
  11. pchukwura

    pchukwura Well-Known Member

    Sep 15, 2010
    184
    0
    0
    Co-Founder/Software Engineer
    Atlanta
    Thanks for the responses!

    Another thing that is pushing me toward C++ is that there is much more information out there as far as say....sample code, game engines etc, that I could learn from or take advantage of.

    I think after all the comments and some thinking of my own, I plan to go down the C++ path. Since i feel somewhat comfortable with C++, i don't think there is any con to going the C++ way.
     
  12. NickFalk

    NickFalk Well-Known Member

    Small word of warning:
    While going the C++ route makes sense, if you want to make other kinds of iOs apps (not games) you really need to know Objective-C to make the most of it. (As Apple's cocoa frameworks are Objective-C based).
     
  13. pchukwura

    pchukwura Well-Known Member

    Sep 15, 2010
    184
    0
    0
    Co-Founder/Software Engineer
    Atlanta
    You are correct. I've been developing in Objective C for about 2.5 years, and have made Mac and iPhone apps, so if I did go down the app route again, I have that knowledge.

    Of course if I did program in C++ for a prolonged period of time (as I plan to focus solely on games for a while) I may lose my confidence as a ObjC developer lol.
     
  14. NickFalk

    NickFalk Well-Known Member

    Well, just like Objective-C, C++ was created to "marry" the object-orientated programming paradigm with C (which is a procedural language).
     
  15. sticktron

    sticktron Well-Known Member

    #15 sticktron, Sep 19, 2010
    Last edited: Sep 19, 2010
    This ties back to the comment about Apple making "their own" C++.

    First their was C. Then the Object-Oriented paradigm came about. Obj-C was invented as a superset of C which had new OO features. A different group invented C++ for the same reason.

    Since Obj-C was used mainly for NextStep, and that's the basis of Apple's system methodology, you find it primarily in Apple development, whereas C++ became the widespread replacement for C everywhere else. Both are supersets of C, and are therefore backwards compatible.

    The thing about Obj-C is that it has strange syntax, whereas many popular languages are C based in syntax (c++, java, JavaScript, actionscript, c#, etc). This makes it a little harder to switch into for new MacOS/iOS programmers.
     
  16. NickFalk

    NickFalk Well-Known Member

    Sorry I just can't leave this alone. ObjC's syntax is only strange if you're already used to dot-syntax. Personally I find ObjC's use of square brackets to make it more readable...
     
  17. FlagellumDei

    FlagellumDei Well-Known Member

    May 14, 2009
    215
    0
    16
    Programmer
    Sorry, my mistake.
     
  18. Yes, I am not sure if the dot syntax was necessarily more popular at the time Objective C was created. I don't think the dot syntax became seen as a standard until after C++ became popular. And Java probably helped to reinforce it.

    But Objective C syntax was based on Small Talk, I think, which was, at the time, one of the pioneering OOP languages.

    Also, Apple didn't invent it's own programming language, but it did, in fact, give it a boost to 2.0.
     
  19. Mr Jack

    Mr Jack Well-Known Member

    The dot syntax existed in C before it was carried to C++. C++ extended the syntax for structs when it introduced classes.

    Back to the OP: I use C++ because that's the language I'm familiar with and most non-iPhone games development is done in. It's a much more widely used language than Obj-C. However, there's not a lot of reason for someone familiar with Obj-C to transfer; C++ is slightly faster but the speed difference is unlikely to make any significant difference.
     
  20. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    That's a very good point, when I was adding Multitexture to Ground Effect all the sample code I could find was old C/C++ based OpenGL samples from at least ten years ago.

    As others have said, Objective C isn't an Apple thing, it can be used on other platforms. I think I'm right in saying that Carmack used it for Quake because he thought it was a better way of adding OO to C.

    Personally, I love the way that C++ extends from C, you can start off by adding a few methods to structures (and calling them classes although the difference is very subtle), using a few virtual functions, overriding a few operators to make vector/matrix maths cleaner and less error prone. Changing your coding style a feature at a time.

    Objective C seems to require more of a total buy-in to the way it works. Or maybe that's just the perspective of someone who learned C++ 12 years ago as a C/assember coder.

    Personally, I only use Objective C where it makes sense. In my library it's basically setup, the run loop, the accelerometer and touch code and mp3 playback.

    Some (maybe all) of that can be done from C but it's not worth it, much better to have code that closely resembles the Apple samples. Also, in some cases Objective C can save a huge amount of time. I spent days writing hundreds of lines of code to play mp3s from C, callbacks, managing streaming buffers etc. Only to replace it with a couple of lines of objective C.

    You can't avoid Objective C entirely. Or rather, you probably can but it will be a hell of a lot more effort than learning a little of it.
     

Share This Page