Difference between Xamarin.Forms and Xamarin Traditional - StackOverflow Answer

Difference between Xamarin.Forms and Xamarin Traditional - My StackOverflow Answer to the question.

Difference between Xamarin.Forms and Xamarin Traditional - StackOverflow Answer

A few years ago I was on Stackoverflow I was looking at some Xamarin related question, and I find this thread: https://stackoverflow.com/questions/43031120/difference-between-xamarin-forms-and-xamarin-cross-platform


... And I was not satisfied with the answers from the community so I just sat down and start typing my version of answer. When I realized that my answer is a bit longer I decided to "migrate" that text also to my blog post.

So this blog post will be in the form of the answer to the StackOverflow question.

Note: Also if you find this blog post helpful or you agree with me, go to the StackOverflow thread and upvote my answer ONLY IF YOU THINK THAT IT IS CORRECT!

Question: Difference between Xamarin.Forms and Xamarin Cross-Platform

My answer was:

When we talk about Xamarin there are two approaches in the development of native apps:
Traditional Xamarin approach
Xamarin.Forms
There is a good quote from Xamarin web site:
"Share code everywhere. Use the same language, APIs and data structures to share an average of 75% of app code across all mobile development platforms. Build user interfaces with Xamarin.Forms and share nearly 100%."
An important note is that these numbers can vary from project to project so this is some assumption for general usage of Xamarin.
And as you can see from the image below about "differences" between these two approaches. Traditional Xamarin approach (Xamarin.iOS and Xamarin.Android) they’re both built on top of Mono, an open-source version of the .NET Framework. To develop those apps you use C# and there is an opportunity to share up to 75% of the codebase as you can see on the image bellow and from a quote from Xamarin.

Using Xamarin Traditional approach you can use a C# as the programming language to write your models, call web services, etc. So you are writing that code logic once and using/share it across the Xamarin.Android and Xamarin.iOS projects, and in those separate projects you are writing code that is specific for that platform and you have access to their APIs.
Also, there is a quote from Xamarin about the traditional approach:
Anything you can do in Objective-C, Swift, or Java can be done in C# with Xamarin using Visual Studio.
And project structure with Xamarin traditional looks like this:
Shared code project: Codebase that is common and reusable for your other projects.
Xamarin.Android: Project for your Android app where you are writing code using Android-specific APIs, writing your UI code, etc.
Xamarin.iOS: Project for your iOS app where you are writing code using iOS specific APIs, writing your UI code, etc.
More info about Xamarin traditional here.
Now about Xamarin.Forms, the best definition is a quote from Xamarin website:
Xamarin.Forms is a framework that allows developers to rapidly create cross-platform user interfaces. It provides it's own abstraction for the user interface that will be rendered using native controls on iOS, Android, Windows, or Windows Phone. This means that applications can share a large portion of their user interface code and still retain the native look and feel of the target platform.
As you can conclude from the text above, Xamarin.Forms is a framework that allows you to write your UI using C# or with XAML with an opportunity to use MVVM... With Xamarin.Forms you can write your codebase and your UI which will be shared across the platforms.
Note: this is a very simple project structure, of course, you can add more project for different layers
Shared code project: Holds your common code base and also because you are using Xamarin.Forms you can write code for your UI
Xamarin.iOS and Xamarin.Android: Code for that specific platform, and some advanced topics such as Custom renderers and Dependency services.
Of course, there are some of the limitations if you are using Xamarin.Forms for example out of the box you can only use UI controls that are common across all platforms. You can read my blog post about Xamarin.Forms the pros and cons here.
I hope that this answer is not confusing for you and as a conclusion in one or two sentences... Using Xamarin Traditional you can share your code logic between platform-specific projects, and with using Xamarin.Forms you can share code logic and also code for UI across your projects.
Note: For shared project and code sharing strategy you can use "Shared Project" and "PCL" this is topic another question so in this answer I was simplifying this and use shared project term for that type of project in Xamarin app solution.


... End of my answer.

Ok, guys that were my answer for that question on StackOverflow, again if you find this blog post correct and helpful for you upvote my answer so it can be more recognizable in the community.

Hope that this was helpful for you and that you learned something new.

Best regards!