views:

484

answers:

4

It is clear that cross compilers will not be allowed by the Apple App Store, so a developer will need to be familiar with Objective-C to create applications for the iPhone.

I was wondering, is there a cross compiler that will take Objective-C application code and rebuild it into a similar Java application that can be packaged for Android? That way, a developer could still learn just one language (obj-c) but put out applications on many devices.

I understand that the Java port would be less optimal than a natively coded application, but could conceivably save a developer some time.

Edit: Yes, the applications would be terrible. But would they not be as terrible as if they had been built by monotouch or the flash cross compiler? Couldn't those same methods be used that these cross compilers use?

+1  A: 

The problem with such a compiler is it would produce terrible applications. Android has a (better) different model of how the application is structured - while a iPhone application is more traditional, an Android application is much better integrated into the system (via activities, view, services and intents).

The biggest challenge is not the main code, but the UI and system libraries. If all views were XIB, there is a small hope.

Yann Ramin
+7  A: 

I've not heard of a cross-compiler that will do what you are asking. Even if one did exists, the bigger problem would be that the frameworks (UIKit, CoreAnimation, etc) are vastly different between the two platforms. Without some sort of common frameworks, all of the code interfacing with the frameworks will have to be reworked.

highlycaffeinated
+2  A: 

Not a chance. In general, translating from a low-level language like C to a (ever so slightly ) higher-level language like Java is going lead to some very sub-optimal code.

But that's not even the worst part - you'll need to translate between two extremely-different application models as well. You'd either have to re-implement most of Cocoa Touch as a shim over Android, or try to figure out what the iPhone app is actually doing and crank out equivalent Android idioms.

A much more likely path would be something like GNUstep, but I don't know if anyone is seriously looking at implementing the UIKit layer for GNUstep, and you'd end up with a native application at the end, rather than a Java app.

Mark Bessey
Objective-C is a higher level language, just as Java is... I have over a decade of Java programming under my belt and now full time Objective-C work since the release of the iPhone SDK (and even a bit before that).
Kendall Helmstetter Gelner
To clarify - you can use things like function pointers, manual memory allocation, bitmasks and bitfields, and other C features in your Objective-C code. A Java program would have to emulate these constructs with something significantly heavier-weight.
Mark Bessey
+1  A: 

There is one project, called XML Virtual Machine, that does sth similar to what you are asking. I was interested in that before i got to know the Objective-C. As far as I knew, cross compiling from Java to iPhone was possible(with some limitations). Project is still in development. You can checkout its webpage at XML VM webpage.

Maybe ppl from XML VM could answer your question(if they plan on creating cross compiling from Objective-C to Java).

But I still claim that making the application twice(for each platform using different languages and tools) would definitely give better results.

krasnyk