Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Targeting/Developing for multiple mobile platforms with one programming language (C#)? Cost-Benefit?

Today it is possible to use C# programming for multiple mobile platforms such as:

  • WindowPhone7
  • Android - Monodroid
  • iPhone - Monotouch

(feel free to edit if I missed some) Of course, it is still programming effort for UI, but main libraries of app can be shared.

We can all thank to a team gathered around Mono project and superhero Miguel de Icaza whose effort is priceless.

What bothers me is, what are the benefits of these options? Is it cost of maintaining one app across multiple mobile platforms less impediment then having to code each library separately for better performance. Learning curve of each language? Being Jack of All trades vs .NET Ninja

Or knowing that binaries of app programmed in native environment are less in size, maybe even optimized better and not to forget that you have to wait support of new platform os updates.

UPDATE: Obviously there is one more thing to consider and that is support. Since Novell is bought by Attachmate Group, all Mono team is laid off. However the core member of the team lead by Miguel De Icaza founded new company Xamarin which will reinvent Mono Mobile development tools from the scratch.

like image 680
nemke Avatar asked Mar 17 '11 06:03

nemke


People also ask

Which programming language is used to develop cross-platform apps?

Ionic. Ionic is one of the most remarkable and popular cross-platform app frameworks, based on AngularJS. It allows developers to use a combination of top programming languages i.e., HTML5, JavaScript, and CSS and Cordova wrapper to access native platform controllers.

Can you use C# for Android development?

You can build native apps for Android, iOS, and Windows by using C# or F# (Visual Basic isn't supported at this time). To get started, install Visual Studio, select the Mobile Development with . NET option in the installer.

What is cross-platform programming?

Cross-platform development is the practice of developing software products or services for multiple platforms or software environments. Engineers and developers use various methods to accommodate different operating systems or environments for one application or product.


3 Answers

In my opinion, the big pro of using one single environment (i.e. C#/.NET) is code portability. And cool things like LINQ that, once you get used to it, you can't live without. However, the few mobile OS's (iOS, Android, WP7) are quite different with regards to UI.

And, if I am not mistaken about your application, it's got a fair share of UI interactions if it is to run on a mobile device. Most mobile apps are like 80% UI code.

Therefore, you'll end up writing a separate set of UI code for each platform anyway -- for example, you'll be writing in Silverlight WP7 (and all the WPF goodness), you'll be writing a completely different set of code for iOS in Cocoa (IB, Views, controllers and stuff), you'll be writing yet a completely different set of code for Android.

My experience has always been that it take a lot of experience to write good UI code on any platform -- e.g. learning WPF/SL is already the nightmare that is, throw in Cocoa Touch and the whole Android mess. Of course you can write three sets of UI that look and feel reasonably similar, but chances are that you'll be trying so hard to reuse code and have common data structures that your UI's will end up sub-par when compared to dedicated apps -- and in this cut-throat world of mobile apps today, a non-super (not to mention sub-par) UI experience means death to your app.

Also, all three mobile environments have different connectivity paradigms, as well as multimedia paradigms. You end up writing three versions, and learning three environments, albeit writing in one language you're familiar with.

The most you're going to reuse is back-end modules. Decision engines, search routines, data-management etc. And even these are going to be problematic because you'll be force to have compromises in your data structures just to enable easy integration with three different sets of UI code working on three different UI paradigms. For example, do you use DependencyObjects for use to bind to Silverlight views in an MVVM model? If you do, it won't work with Cocoa's MVC model, and you have to code those bindings separately.

And since not all mobile environments enable you to use the full set of functionalities -- for example, MonoTouch for iOS does not generic constructs that cannot be determined at compile time. You're essentially using a very small subset of .NET (and must constant be reminding yourself what functionality can be used where) just so that you can run them all on three different platforms without significant changes.

Now image having all these limitations when you are writing for the WP7 platform, which supports the entire .NET features set. I don't know about you, but I'll go crazy. And your WP7 app is never going to be even close to being competitive with other apps out there.

In my opinion, the pain and the compromises are not worth it. You'll end up with three so-so apps, which people in neither of the platforms are going to like.

Unless all the goodness lies in your app's back-end logic, and it is so good that people are going to ignore UI issues just to get to your app's back-end functionalities. In my experience, this almost never happens.

like image 70
Stephen Chung Avatar answered Nov 04 '22 17:11

Stephen Chung


The biggest advantage for me is the ability use reuse the business logic and communications code between mobile platforms. Yes, I have to write the UI over and over again, and it takes time to get your head around that, but at least my base platform is reusable.

In my experience when moving to a new platform, it takes me a lot longer to learn the UI framework than to learn a new language.

like image 43
vlad259 Avatar answered Nov 04 '22 17:11

vlad259


Since the accepted answer had been written in 2011, a couple of different frameworks have emerged, which bring MVC and MVVM patterns to Mono for Android and MonoTouch, which helps quite a lot when developing applications for these targets.

For MVC check out the project called MonoCross

For MVVM check out Stuart Lodge's MvvmCross

The latter contains a lot of code for opening images on the three platforms, composing e-mails, opening webbrowsers, playing sounds and much more. It aslo handles navigation between ViewModels.

like image 2
Cheesebaron Avatar answered Nov 04 '22 17:11

Cheesebaron