Why Xamarin is the future of mobile development

Why Xamarin is the future of mobile development

I feel like Xamarin is very trendy nowadays. And there’s a good reason for that. When someone creates a mobile app he wants it to be available to as many people as possible. That way he could earn more if app is made for monetization purposes or he could increase market reach if app is only a support for the main product. Whatever the reason is, making app available for all major platforms is important. And there we have: iOS on iPhones and iPads (and watchOS for Apple Watches), where we use Objective-C or Swift, Android with many different versions where we use Java. We also have Windows with its unified platform which includes Windows desktop, Windows Mobile, IoT and other devices where we can create software with C#.

 

The old way of developing mobile apps

We decide to create an app. In the old days we would have to create 3 (or even more) apps. Each one in different programming language: Objective-C, Java and C#. We have 3 separate code bases, 3 separate teams of developers. I assume that one person won’t create app for different platforms as this would require him to know 3 languages, be proficient in them and have enough time to make 3 apps. That simply doesn’t calculate. If someone has so much knowledge he would certainly have higher rates, but still he can only work on one app at the time, so it’s obvious that it would be more reasonable to have developer(s) for each platform. That way we could save a lot of time as all 3 apps would be in work at the same time and we would probably save some money too (although not that much).

Now think about these 3 apps. They are separate. From user’s perspective this may be one, the same app, just for different platforms and he could expect identical functionality, the same experience (adjusted for each platform’s guidelines). But if we have 3 code bases then keeping everything in sync is more difficult, requires much more work. It is not only writing code 3 times, it is also communication between teams so that everything works as expected in every app. It is more management work and maybe also design work.

Then we release the app, we want to keep it updated, add new features, fix bugs. We find bug in one platform, we need to check if it also exists on others. We add a new feature and we again do all the work 3 times.

 

Hybrid apps

Today we have more possibilities. There are hybrid frameworks where we can make apps in html/js and they can run on all major platforms. However I never liked them. There are 2 main problems I see with them.

  1. Performance – it is worse than native and users often expect top performance. Although this is not always a deal breaker.
  2. Language – we use html and js, which are really messy in my opinion. They are much harder to maintain than compiled code as C# or Java. They don’t have as awesome IDE as Visual Studio which supports developer in many ways and accelerates app creation process. Developer will be able to create app faster and write better code in C# than in html/js (if he has similar amount of experience in both languages). However that is only my opinion.

 

How we can create mobile apps today

Except of hybrid app we have native cross-platform apps – apps created in Xamarin. What do we gain here? We write apps for 3 platforms in one language, with one code base. Whole process is greatly simplified. We can use one team of developers, cut a lot of work in writing code, management, communication and maybe also design. That’s a huge time and money saver. Look at the image below.

 

Sharing code in Xamarin is great time saver

Sharing code in Xamarin

 

Whole backend code is shared. Whatever we do in our app, we write it only once, not 3 times. The only thing we have to write 3 times is platform specific code and presentation layer – in simple terms this is UI, look of the app that user see. But if we want to share the UI we can also do that. Xamarin created another layer that lets us share the UI code – it’s called Xamarin.Forms.

 

Share even more with Xamarin.Forms

 

Sharing code in Xamarin.Forms includes sharing UI

Sharing code in Xamarin.Forms

 

As you can see in the image above, Xamarin.Forms lets us share UI code. We can write it in C# or in XAML – this is similar XAML to the one created by Microsoft for Windows Phone although it’s not exactly the same. With Xamarin.Forms approach we have to write only very little code 3 times. This is code that is specific for each platform, like handling push notifications or maps. The good news is that Xamarin community is growing, Xamarin is becoming a really trendy thing right now. Because of that there are more plugins available, which do some work for us. For example, we have plugin for maps – that means we have map already in Xamarin.Forms and we don’t have to write platform specific code 3 times, because someone did it for us. This is true for many most used features, so that’s additional point for Xamarin.Forms.

Xamarin also created a testing platform, Test Cloud, where we can test app on many different devices, with different system versions. We don’t have to buy a lot of devices ourselves, so that’s also great.

 

Any drawbacks?

Yes, there are some. Xamarin.Forms has worse performance than Xamarin, which is often noticeable. It may be not a good solution for all consumer apps (it’s fine for some of them), but it will most likely be great for enterprise apps. The plus is that Xamarin.Forms is developing fast right now, Xamarin team is aware of performance issues and they are working on making it better.

Another thing is that Xamarin itself (not Forms) may be slightly slower than native apps created in Java and Objective-C, although it is not always the case. Xamarin lacks a bit in rendering speed, but the rest is on par with native apps, so we don’t really have to worry about performance here. Pages may open a bit slower than in native apps, but the difference is small and probably unnoticeable without side by side comparison. I made 2 posts about Xamarin performance some time ago, you can read part 1 here and here’s the second part.

Anything else? Well, Xamarin is another layer of code, so it has it’s own issues and bugs. They are sometimes annoying, but in my experience they are not significant enough to stop using this technology.

 

What awaits us in the future

I really like what I see now. When I first had heard about Xamarin I think it wasn’t called Xamarin yet. It was some very early version. When I tried it the experience was quite rough, debugging was very slow. It wasn’t that inviting. I stopped using it as I thought that creating app in this would be painful. Today it’s still the same technology, it does the same thing, but the experience is so much different. It works really great most of the time. The devs in Xamarin didn’t stop, they pushed forward, they worked on their product, they improved it significantly during these years and that’s amazing. It will only get better.

When I think about the future I see Xamarin in it. I see how companies and single devs are creating cross-platform apps with less effort, in less time, with smaller budgets. This is what we call innovation. This technology helps people to automate things that can be automated, so we can spend our time and resources on other things that require our attention.

If you want to create a mobile app and are wondering how to approach it then I think that Xamarin may be the right answer. Especially if you are C# dev or you have C# devs in your company.

Are you hesitating? Check who’s with Xamarin. Many big companies already use one of Xamarin products as shown here. And there’s more. Xamarin is getting traction right now, you can see it more and more often.