In 2013, Xamarin announced Xamarin Studio, a cross platform for iOS, Android, Mac and Windows. This tool allows developers to write solely in C# and share the codebase across multiple platforms.
With an increasing interest for this approach to development, we decided to take a look and see what this cross platform tool entails and how it could influence the future of app development.
Native applications are written in platform specific languages, so it stands to reason that three apps (iOS, Android and Windows) will take three times the development effort. This is, in many cases true. Companies will often have different teams working to create apps that are tailored towards each platform.
Clearly, this can be quite an expensive and time consuming route to go down for many companies, but one that has generally delivered a far superior user experience.
Xamarin is attempting to achieve a platform that can share code across these platforms, whilst still produce a native application at the end of it. The aim is to help companies cut down on development effort and as a result, save costs.
Before we dive into Xamarin, it’s probably worth refreshing our memories on Cordova, the other major cross platform solution.
Cordova (formerly Phonegap) apps are HTML applications wrapped up in a native layer. If you do not require the use of any native APIs, Cordova allows you to share almost 100% of the code. For this to work on different devices, there need to be tweaks to the code but it can make it easier to deploy apps across different platforms. This is much the same as creating websites that run in different browsers, some tweaks are required, but the majority of the code is shared.
The main downside to this approach is that the UI is not native and therefore the app never really “feels” 100% like a native app. Having said this, webviews on each platform are getting better all the time, so the feel of a Cordova application is getting closer to native all the time.
If the goal is to have a single developer on the app, and to share as much code (including UI) as possible across the platforms, providing the app is not too complex, Cordova can be a good solution.
So where does Xamarin fit into the equation? Well, Xamarin claims that up to 75% of code can be shared across the three platforms, leaving the last 25% to be platform specific. The idea with Xamarin is to make apps feel more like native apps, rather than web apps wrapped in a native layer.
As a rule, the element of a Xamarin project that cannot be shared is the UI, and we do not just mean the actual display layer, but UI in the sense of the entire navigation stack, transitions and UI. Essentially, this means that everything the eye can’t see is shared across platform, with the all important front end being customised for each platform.
Xamarin does have a new project that attempts to remedy this, Xamarin Forms. Despite what the name suggests, Xamarin Forms allows for a subset of basic screen types to be used across all three platforms. It’s a nice idea, but not yet ready for production apps in our experience. There are also such a small set of screens available that only very basic applications can currently be built with this, though it’s a project worth keeping an eye on.
Things to consider
While the platform can support all three major platforms and produce native applications, there are some key things to consider when using Xamarin:
- It is a proprietary platform – Xamarin is not open source, and it is not free. There is nothing to suggest the platform may be sold, but it is definitely something to consider in your decision making. If five years down the line the platform is no longer around, your app will need re-writing.
- It is relatively new – The tools are still new, and in our experience Xamarin studio is not as stable as the native dev tools (Xcode and Android studio in particular)
- It costs – an enterprise license for one developer to be able to produce an app for all three platforms is not an insignificant cost so bear this in mind when making your decision.
Many people expect that creating apps in Xamarin will be straightforward and easy. Though it certainly makes life a bit easier, it’s still worth exploring creating custom apps. Much of the work that Xamarin is trying to remove can be handled by creating the right APIs or using middleware for backend systems. Largely, with the right backend in place, creating the frontend becomes much easier.
It’s also worth noting that using the developer tools for Android and iOS can make for lean, smoother apps as they are coded in the right language. As with any development choice, it comes down to establishing the user experience you want to create and working backwards from there to choose the right development approach.
Here at Mubaloo, we’re continually gaining experience with the different tools available to create apps that deliver what companies need. Xamarin and Cordova are two that we use, when it makes the most amount of sense. As developers, it’s important that we have teams who know each platform inside out to create the best apps possible.