★ TouchArcade needs your help. Click here to support us on Patreon.

C++ or C or Objective-C

06-14-2012, 10:28 AM
#1
Joined: Feb 2012
Posts: 65
C++ or C or Objective-C

Anyone one had any experience writing games in C++ or C for iOS? this article seems to say it's much better performance wise to write them in C. Thoughts?


http://www.vellios.com/2010/08/22/wh...e-objective-c/

Games: Swangle for iOS
Twitter:JDunay -- I'll always follow for a follow

Http://Swangle.jamesdunaydesign.com
06-14-2012, 12:34 PM
#2
ObjC is a great modern language and easier to do things, but for games, I use C/C++ because: 1) performance wise and 2) cross platform.

06-14-2012, 03:08 PM
#3
Use C++ for everything you can, and ObjectiveC for the rest. Avoiding ObjC will allow you to make your game cross-platform.

Independent developer of Alien Space, Alien Space Retro, and now Annihilate

For more information and latest updates, join us on Facebook: https://www.facebook.com/AlienSpaceGame
06-14-2012, 03:20 PM
#4
Thanks for the article. The comment saying that what is slowing down the game are calls to NSMutableArray is very interesting... I code in Obj. C because I just love the language and knowing C it was easy to learn, but I'll consider using C for parts of the code to gain in performance... wrapping things in objects is very convenient, but if performance is an issue it's clear it's better not to do it...

- makaGeorge (www.makasoft.net)
06-15-2012, 10:08 AM
#5
Joined: Nov 2008
Location: Baltimore
Posts: 205
Quote:
Originally Posted by makaGeorge View Post
Thanks for the article. The comment saying that what is slowing down the game are calls to NSMutableArray is very interesting... I code in Obj. C because I just love the language and knowing C it was easy to learn, but I'll consider using C for parts of the code to gain in performance... wrapping things in objects is very convenient, but if performance is an issue it's clear it's better not to do it...
Some general notes

1. ObjC dynamic function dispatch is about x2 slower then C++ virtual functions

2. ObjC compiler does not inline code,
C++ functions, Templates can be etc.
in some code this is a massive speed win vs Objc.

3. All this given... ObjC is Perfectly fast enough to make most apps and many games... heck ObjC ran fine on old 68000 CPU NEXT boxes
So don't worry to much... also... you may find in tight loops with a lot of function calls it would be much faster to code those functions in C or C++ and call that from ObjC.

4. Anyhow its perfectly fine to mix and match ObjC, C , C++ , Lua etc as needed.

Last edited by TheBunny; 06-15-2012 at 10:40 AM.
06-15-2012, 02:28 PM
#6
Objective-C is fine but it has terribly slow libraries. As long as you avoid the libraries then the only issue is with really tight loops, where you want to juice every last bit of performance out, use C.

Of course if you don't use the obj-c libraries your mostly coding like you would with C except with classes and properties.

C/C++ is really the way to go. Obj-C locks you into apple's platforms, making it more difficult to release ports and there's many gamedev libraries for C/C++ that you will probably want to use anyway.
06-16-2012, 07:09 AM
#7
You can use Allegro with C or C++. It's a cross platform game engine.

I'm an indie game developer.
My website
Twitter
Facebook
06-17-2012, 12:31 PM
#8
Joined: Feb 2012
Posts: 65
What about a game like infinityblade? or possibly NOVA 3? what might those be written in?

Games: Swangle for iOS
Twitter:JDunay -- I'll always follow for a follow

Http://Swangle.jamesdunaydesign.com
06-17-2012, 01:33 PM
#9
Quote:
Originally Posted by jDun1212 View Post
What about a game like infinityblade? or possibly NOVA 3? what might those be written in?
Most games written by professionals are written in C++.

Independent developer of Alien Space, Alien Space Retro, and now Annihilate

For more information and latest updates, join us on Facebook: https://www.facebook.com/AlienSpaceGame
06-18-2012, 01:20 AM
#10
Joined: Sep 2010
Location: Morestel, France
Posts: 572
+1 for C++. Mainly for cross platform reasons.

JC