Disclaimer: my goal is not to use cross-platform frameworks like Unity.

I am currently planning a mobile game which I intend to first launch on iOS. However, I am wondering if it is better to write everything in Objective-C, thus locking the code into the platform, and to do a complete rewrite for other platforms (ie: Android). The other option would be to write the game logic in C or C++ and to only write the code that interfaces with each OS in the preferred language (Objective-C(++) or Java).

I understand that this must depend on the size of the code base, so what program size should mark the separation?
Finally, if I write cross-platform code, should I stick to C (since Objective-C is a superset of C, making it easy to use C and to use the code samples and because the NDK and the JNI interfaces are more C oriented)? The only advantage I see with C++ in that case is the fact that it is object-oriented and thus it is easier to represent game entities).

Unity basic license for Android and iOS is free for a few weeks.. I realize you seem to be against it (assuming cost) but once you write a few apps for a specific platform, you may change your mind.
–
Chuck DMar 12 '12 at 3:26

1

@RubberMallet There are tons of reasons not to use Unity, "assuming cost" is a wild and likely wrong assumption.
–
LohorisMar 13 '12 at 13:55

Stating that there are 'tons of reasons' for or against any platform sounds a bit fanatical. I would be interested in knowing what you are thinking of specifically. Any platform is strengths and weaknesses but not everyone has thousands of dollars for pro licenses and such. Unity is a good platform for certain games but obviously it's not for everyone, I realize this but it may be worthwhile unless you want to handle significant plumbing on your own...
–
Chuck DMar 13 '12 at 18:05

To counter the argument at the end of the linked article, I have talked to a handful of mobile developers that all share the same rhetoric, if you are looking to make an income from mobile development you should target iOS. The Android market has proven itself to not be as willing to pay for what the iOS market will.
–
JamesMar 11 '12 at 19:54

I'm into XNA for Xbox360 development, and some of the developers that have written games for Xbox and PC in C# reported that porting to C++ and other platforms wasn't very hard at all.

Full portability is probably not a good idea, as the UI should be tied to the platform. This means you'll probably need to design specific UIs for iPad, iPhone and various Android devices.

The game logic on the other hand, can be written in such a way that it does not reference the OS directly, allowing to share the code among platforms, or at least make it painless to port between languages and platforms.

You could rewrite everything for both platforms, but that would take a lot of time. Another option is, like you suggested, to write the OS dependent code in Objective-C and Java and then write the core of the app in C. If it is a little app, then the first option shouldn't be too much of a hassle, especially if you're just embedding a web page or something similar. But for larger apps (ex. 3d multiplayer games) the second option is better. You said you didn't want to use a cross-platform framework like Unity, but if you went with the second option you'd essentially be writing your own library. If your game requires a lot of OS specific things than this could be difficult to implement as well. And there are some frameworks which do almost exactly what you said (implement OS specific stuff then let you use C or C++ to write code) like MoSync.

As for C vs C++, if you really like C++ and can't stand to code in C, then it's worth using C++, but otherwise I'd say stick with C because it could be very difficult to use C++, though I don't know for sure. I'd look into using C++ with the NDK.

While this falls in line with some of the other answers, I'll make this case: Cross-platform development can mean not only two different platforms at the same time, but also the same platform at two different times.

By that, I mean that every line of code that depends on a platform/OS specific feature is one that will have to be rewritten should the exposed functionality of the platform be changed at a later date. If you keep your codebase platform agnostic, you only have to worry about updating the OS abstraction layer to accommodate new changes.

you definitely want to think cross platform. iOS may be most lucrative now but a lot of developers are now quietly moving to Android. if your game is successful, you will want to localize and release in other markets and, for example, Asia is more of an Android world.

There are platform independent toolkits, like Unity, so investigate those. You also have HTML5 as a possibility.

bottom line is this - if you are successful, you will want to go cross platform. If you are not, that could also be because you did not try all platforms. so better think cross platform right away :)

-1 This advice is just unsubstantiated assertions. There are no figures presented, there is no insight into why people might be moving to Android (maybe they are not even going cross-platform), and the answer never actually addresses why someone would want to do it. It just asserts: "Well, some people are doing it. If you are successful, you will want to do it." (okay, I hear you, but WHY?)
–
doppelgreenerMar 12 '12 at 3:46

-1 he said, in the very first line, his goal was not to use frameworks like Unity... and you suggest just that.
–
LohorisMar 12 '12 at 8:19

@JonathanHobbs omg! what a way of welcoming someone new! "there are no figures presented" - ok, sorry, next time I will not answer till I have figures. "okay, I hear you, but WHY" read it again
–
Greg BalaMar 13 '12 at 13:41