Xamarin vs. PhoneGap

I recently had the opportunity to write a Xamarin app for the first time.  It wasn’t Mike Berrymananything complicated – basically a CRUD application that would list items for the user with the option to add, edit and delete – but it afforded me a chance to compare and contrast with the way I’ve been writing mobile apps for the past few years.

Since 2013, I’ve been creating business mobile apps using PhoneGap (also known as Cordova) from Apache.  In a nutshell, PhoneGap allows for users to create mobile applications using HTML, CSS and Javascript, basically creating a mobile website that is hosted on the device itself, and has access to device functionality like the camera or GPS.  Without going too much into it, one of the huge selling points of PhoneGap was the fact that is was cross-platform and a single code base.

Xamarin also provides these things, however it wasn’t until 2016 when Microsoft acquired Xamarin that it became free to use.  And finally, a few months ago, I took the dive into Xamarin development.

Now I will freely admit that I’m a newbie to Xamarin, and conversely very experienced with PhoneGap.  That being said, here are my takeaways from my first project in Xamarin, in the context of being compared to PhoneGap:

Xamarin Pros

  1. Xamarin is more closely tied to the device hardware.  PhoneGap apps are technically compiled applications that on the surface work just like any other mobile application, but PhoneGap apps are really just a full-screen WebView that’s displaying your HTML/CSS/Javascript with hooks into the device hardware.  That means that if the Android or iOS WebView can’t do it, your app can’t either.  With Xamarin, your code is translated directly into Java or Objective-C (or Swift) so it’s like you wrote your app in the native language for the Android/iOS device.  The most obvious benefit of this is performance.  Not having to do things “in a browser” means the device hardware is utilized much more effectively.  The being said, for business applications performance usually isn’t really a concern, so in my world this is a tentative pro.
  2. Xamarin has better storage options.  In PhoneGap, since we’re technically in a browser, the device storage available to our app is based on whatever the operating system limits for the WebView.  If we want to store data in local storage or memory, the operating system has higher restrictions on how much can be stored for WebView (aka Browser) sources than for other app sources.

Xamarin Cons

  1. Customization.  Xamarin worked great when I wanted to do anything “out of the box”, or already provided by the Xamarin framework.  However, as soon as I wanted to do something custom, it became a huge pain.  For example, I wanted to implement a collapsible stackpanel to hide sections of the form that weren’t needed.  Normally this would be simple enough to do by simply hiding the section when you click on header or something, but I wanted it to actually animate when collapsing/expanding.  This basically boiled down to having to dynamically alter the height of my container, and when doing that for both Android and iOS, I had to implement that functionality individually in both operating systems, then consume and use the custom control in my shared code.  It just felt overly complicated to me.
  2. I had worked on Silverlight before it was discontinued, so coming into the Xamarin world I was already familiar with XAML.  However I can see someone who doesn’t have any experience with XAML having quite the ramp-up time.  What immediately jumps to mind coming from the web development world is the whole concept of widths/heights not being static or percentage values, but more being “ratios”.
  3. When in a Windows environment, if you want to develop for iOS, you need to be networked with a Mac.  For PhoneGap, you still need a Mac in order to actually build your application, but all you need it for is to create a few files necessary for the build process to compile the app.  With Xamarin, you need to be connected to the Mac in order to run/test your code (for iOS).  Effectively, you’re much more dependent on the Mac for Xamarin development.

At the end of the day it’s not like I have any regrets writing the application I did in Xamarin, but I think if given the option between Xamarin and PhoneGap, at least for my line of work, I feel PhoneGap is a better option.  So unless there’s a specific reason to go with Xamarin, PhoneGap will be my go-to.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s