views:

64

answers:

1

Does the fact that different mobile platforms can use similar languages implies that you can reuse classes between these platform ? For example c++ code on iOS, Android and Symbian devices. Or is there some other things to take into account, libraries, etc. ?

In the same spirit would it be possible to share C# code between iOS, Android and Windows Phone using MonoTouch and MonoDroid(eventually) ?

Edit: Would it be possible to share the UI code between MonoTouch, MonoDroid ?

+1  A: 

No, the languages are definitely too different. To be able to reuse classes they would have to be written in the same language. And since Apple have been kicking out every language except Objective-C from iOS, you won't be able to reuse code. The state of MonoTouch after Apple's (outrageous [subjective]) decision [1] is now very much in doubt.

However, in typical dictatorship fashion [subjective again], Apple have not been completely consistent, so they have not prohibited the use of technologies like PhoneGap ( http://phonegap.com ) or Titanium ( http://www.appcelerator.com/ ). There you write your application in HTML5, Javascript & friends. If you can live with writing apps using these techniques, a cross-platform approach with only one codebase is still possible.

And of course, remember that algorithms are not language specific. Classes in different langages can often be made almost identical in function, although you'll have the disadvantage of having to maintain several of them.

Edit:

Clarifications from discussion:

  • There is actually support for using C++ classes [2]. That opens up possibilities of code sharing of more abstract parts of an application.
  • The state of MonoDroid seems to very much unclear. The discussion referred to in [1] is long and have several strong answers pointing in both directions. It's important to remember that Apple's de facto target in their new licencing clauses are Flash, not cross-platform frameworks in themselves, no matter what Steve Jobs says [3]. That leaves open the possibility that Apple may want to silently allow apps based on MonoDroid or other cross-platform frameworks.

[1] As usual, this is not 100% clear, for example see this question: http://stackoverflow.com/questions/2604033/is-monotouch-now-banned-on-the-iphone

[2] http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCPlusPlus.html#//apple_ref/doc/uid/TP30001163-CH10-SW1

[3] http://www.apple.com/hotnews/thoughts-on-flash/?aosid=p204&siteid=1503186&program_id=2554&cid=OAS-EMEA-AFF&tduid=fb90c7ac85c9a334decb42b892cda59b

Jacob Oscarson
Outrageous is a pretty good description - certainly some variation thereon is barely subjective.
Murph
But they could be written in the same language [c++ for example](http://stackoverflow.com/questions/270455/is-it-possible-to-program-iphone-in-c "test") or am I missing something ? Also, about mono, it seems that they are [still accepting these apps](http://stackoverflow.com/questions/2604033/is-monotouch-now-banned-on-the-iphone/2714999#2714999 "test"). But I agree it would be dangerous relying on the fact it's going to stay like that.
DrDro
About HTML5, I was concerned that you would have a lot less possibilities then with a native app. But I guess the code I would be able to reuse (or not) on different platforms would have the same limitations anyway.
DrDro
Oh, didn't know about that C++ support. Always good to learn new stuff! Re HTML5, yes you do have a bit less possibilities than with native. It will have to be evaluated on a case by case basis weather the most important factor is cross-platform support or power.
Jacob Oscarson
Re the status of MonoDroid, yes, as I note with the (edited) link about weather it's status is go or no go, it's indeed far from clear. The real target for Apple's licencing attack is actually Flash support, MonoDroid is just collateral damage. The most diplomatic way for them to proceed would of course be just to silently allow MonoDroid apps as long as people doesn't make to much fuss about it.
Jacob Oscarson