XamarinMobile app developers usually know Android (Java) or Objective-C but not both. If you have worked with Objective-C before then you know that to an Android developer it looks like Greek, meaning something entirely foreign. Moving from Android to Objective-C programming is not just a matter of learning a new syntax, like with some other programming languages. Instead, it requires a new way of thinking.

If you need to program Android, Windows mobile, and iOS devices, what can you do short of hiring three different teams of programmers or spending the downtime needed to learn the three different languages? The obvious answer to that is to get the developers to all use the same programming language.

This is what Xamarin does. Developers write C# code that gets compiled to the three main platforms; this code uses Xamarin libraries that map to iOS, Windows Mobile, and Android functions. Programmers develop this using either the Xamarin Studio or using Visual Studio that C# developers already know.

Xamarin says, “Anything you can do in Objective-C and Java can be done in C# with Xamarin.”

Native Runtime

Xamarin is not an interpreted programming language, instead the code is compiled into native iOS and/or Android format. This makes it possible to write apps that need to respond quickly, like games. Plus it makes for smooth scrolling and handles complex visualizations. What makes this possible is the use of Mono, which is an open source implementation of Microsoft’s .Net framework.

You might think that, on Android, Xamarin would translate everything to Java bytecode and then run that through the Android Java Virtual machine called Dalvik. But that is not the case. The company says that on Android “C# performs better than Java”. This is because Mono is its own runtime. Xamarin compiles C# into Java for Android. Similarly, on iOS, Xamarin uses the same LLVM compiler as the C and C++ code used to power iOS. That gives you native iOS code.

Xamarin Projects

The way you develop a Xamarin app is you program the business logic in a shared library or shared project file. Then the developer typically creates a different project for each platform, each sharing the same business logic. The different UI projects are to accommodate the differences in the UI for Android, iOS, and Windows.

To give an example of that, to create a Circle image for each device type you would create three Xamarin projects. The business logic is shared between the projects. Then each project has a different Circle renderer for the UI. For example, Xamarin uses the Canvas class for Android, while on iOS it uses the CALayer of the Xamaran UIImageView class. The benefit of all of this, is that code is written in C#. Plus the C# code (i.e., the business logic) needed to access the web services, write to the database, persist objects, and so forth is written one time.

What about Objective-C and Java code you have already written? Xamarin supports initiating objects written in other languages. This means, for example, all of those advanced asynchronous classes you have developed in Java with dependency injection will work on Xamarin. The same is true for iOS objects.

At Seamgen, we have adopted Xamarin as one of our development tools. We also develop with Object-C and Android, depending on the needs of our clients. The Xamarin approach speeds development, reduces time-to-market for our customer’s new products, and reduces development costs.