Could you please tell me which language to use...

Member
Posts: 30
Joined: 2009.04
Post: #1
Hi guys my name is filfil96 (for those of you that don't know me) i've been coding in c++ for 2-3 years now and i've begun in SDL.Grin

I wanted to start coding iPhone applications, but i have one little problem:
I don't know which language to useAnnoyed
A lot of people tell me to use Cocoa others tell me to use Objective-C, etc.

So basically:
1. What programming language do i use to make applications and games on the iPhone and iPod Touch?
2. What programming language do you recommend and why?
3. Where could i go to learn some basics about that programming language?
4. Which books do you recommend that teach that programming language?

Thank you very much in advance, filfil96

OMG! IT'S A SQUIRREL!!!
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #2
filfil96 Wrote:A lot of people tell me to use Cocoa others tell me to use Objective-C, etc.

Objective-C is a programming language. Cocoa is an Objective-C API used on Apple platforms.

You can find plenty about both on Apple's developer site.
Quote this message in a reply
Member
Posts: 30
Joined: 2009.04
Post: #3
Hmmm... i see, so let me see if i understand: First i learn Objective-C then i learn cocoa as it's APIHuh

Ok, oh and by the way, is there any good books on objective-C and Cocoa development or any good online tutorials that you could point me to?Wink

Thanks in advance, filfil96

OMG! IT'S A SQUIRREL!!!
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2009.05
Post: #4
filfil96 Wrote:Ok, oh and by the way, is there any good books on objective-C and Cocoa development or any good online tutorials that you could point me to?Wink
I came from a 10-year Windows C/C++ background and I found this book excellent for learning Objective-C;

Stephen G. Kochan
"Programming in Objective-C 2.0" (second edition)
ISBN 0-321-56615-7

Once you're comfortable with Objective-C, I'd move on to this one;
Aaron Hillegass
"Cocoa Programming for Mac OSX (second edition)
ISBN 0-321-21314-9

Hope that helps,
Lindsay
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #5
I think it also depends on your goal. If you want to make high framerate games, then stick to c++. If you want to make an App like a tip calculator, or a weather app or something like that, you prob should do objective c because of its elegance, and all the apis that are provided by apple for nice gui components. Objective c is very slow for things that need to pull off 60 frames per second.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #6
kendric Wrote:Objective c is very slow for things that need to pull off 60 frames per second.

This is a false generalization. There's some overhead in Objective-C message dispatching, but 1) it won't necessarily slow down your program at all, and 2) there are some easy optimizations you can do in performance-critical code (see -[NSObject instanceMethodForSelector:]) in the extremely unlikely case that it's actually a performance bottleneck.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #7
I disagree. In my tuning I got a huge boost out of replacing objective c code with c code in various areas relating to collision detection. My game loop time dropped in half without any actual logic change. There might be a way to hack your way around that but doesn't that defeat the purpose of using objective c?

The main culprits were NSArray, property accesors, and making something procedural instead of allowing any messages to happen(those are pretty slow). Originally i had about 30% of cpu listed in the catagory of obj c message or whatever it is in shark that represents overhead from function calls in objective c.

I am only a few months into this language so I don't profess to be an expert. If you have more data I would love to hear it.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #8
My point was that it depends entirely on how you use the language; it doesn't intrinsically slow you down just to use the language at all. If you're making heavy use of NSArray and other such things in performance-critical code, then yes, you may have created some significant overhead from message dispatching and need to optimize. This is not, however, reason to throw out the entire language as your previous post implied. You can still write a high-performance program using Objective-C if you're careful about how you use it in critical sections of code.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #9
I agree with what you said. I think basically anywhere you plan to execute multiple times a frame should avoid having [ob message] type calls and self.property calls. If they are once per loop, or rare things like actual collision impact handling or creation of things then its fine. It would also depend on your loop size. My game has like 50 "actors" at most but if your code had 500+ you might need to ditch objective c messaging for their handling as well.

Just to play devils advocate, you could also argue that hybridizing your code makes it unportable and you should pick one or the other Smile

A final note, avoid using conformsToProtocol in your main loop. Doing so causes something like a 5 deep nested function call, wherein arrays are created and other activities happen.
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #10
kendric Wrote:Just to play devils advocate, you could also argue that hybridizing your code makes it unportable and you should pick one or the other Smile

Oh, totally in agreement here. My most recent projects have been written with a 100% portable pure C core, and thin layers of Cocoa/Win32/whatever makes the most sense for each platform it's compiled to. On the other side of the coin, though, I hear that GNUStep is pretty usable these days (though I've never gotten it working myself), so using Objective-C might not be as unportable as it used to be...
Quote this message in a reply
Member
Posts: 30
Joined: 2009.04
Post: #11
Thanks guys! this helped me heaps.

i'll be sure to check out those books by the way.

filfil96

OMG! IT'S A SQUIRREL!!!
Quote this message in a reply
Post Reply