how much xamarin and other cross platform api,s are good?

Started by
5 comments, last by SimonForsman 8 years, 12 months ago

hi.

my question in summary is: is xamarin a perfect replacement for native programing for android ios and.. other supporting platforms?

these days i see many people just start their projects using xamarin. first of all i want to know how it really works? does it work like script language and c# is just syntax of c# and all command and code are translated to for example java android sdk codes or its compeletely different?

and if its really good so there should be no more sdks and java programming and everyone could do all his project in one time coding for all platforms.

is it good for all those platforms devices like cameras, wifi,bluetooth, sound recognition and....?

thank you for helping

Advertisement

Xamarin's two products are:

  • Xamarin.iOS
  • Xamarin.Android

Each of these is a C# wrapper around 100% of the platform APIs. This means that with Xamarin.iOS you get access to 100% of the iOS SDK APIs, just as if you were using Obj-C or Swift. And with Xamarin.Android, you get access to 100% of the Android SDK APIs. The only difference is that it's all in Obj-C, Swift, or Java. It's all in C#. Which is great because you only need to deal with ONE language while writing the app. Plus, any code that is not specific to one platform or the other can be shared between platforms. This means that large amounts of your code only needs to be written once, not multiple times. This usually means data models, view models, application logic, services, http clients etc. The UI portion of the app is where your code will diverge, because the UI APIs of each platform are so different. iOS user interfaces are built very differently from Android user interfaces. BUT, you still get to write all that UI code in C#! So, again, you only have to deal with one language. And C# is a really awesome language, for many reasons.

So, to answer your question: yes, Xamarin is a "perfect" replacement for native SDKs, because it gives you EVERYTHING that the native SDK APIs do.

There are many reasons to choose Xamarin. You should watch James Montemagno's talk about it here:

...

well... thanks for your answer but i think i need deeper answer.you just talked like a xamarin advertiser like xamarin blogs say. for example:

c# is not native language of ios and android. so my main question was how it translates c# for these platforms. does it just translate c# code to java or objective c code or....? dalvik is just made to run android apps on it. dalvik has its own byte code. so there is a compiler like dex compiler that translates java byte code to dalvik code. so how really mono or xamarin makes that? you say xamarin doesnt work for dalvik or in some way xamarin removes use of java?

in the end i think xamarin just generates java code equivalent to your c# code. more or less.

so if im right it means xamarin works like an scripting language and it runs much slower than a native code and these translations cant be without bugs and problems

http://xamarin.com/faq

It says on iOS its compiled to a native ARM executable ahead of time, on android it doesnt explicitly say that (see this stackoverflow answer for reasons why). And it says ("your Xamarin app is compiled to a native binary, not interpreted") without specifying which platform, so both probably.

o3o

Most systems are now using LLVM, if something is using Clang it is either using LLVM or they are planning to switch to LLVM. smile.png as far as I can tell.

So you sort of get portability at the low level, this doesn't help with higher level stuff though.

This is when you usually get platform specific code libraries, compiled with Clang that have to be linked in.

Some systems are cleverer than that and use late binding to give you binary portability. The easiest way to think of that is even if you call a system function what you are actually calling is a stub which gets bound to a real function at load time.

I haven't looked at xamarin much myself, I worked on AGP and that gave you excellent binary portability but couldn't run on IOS because it required executable memory.

However in principle, it is possible with LLVM and some clever code to get excellent speed and platform portability in a package that is easy for a developer to use.

Someone who has used xamarin will have to tell you if that is the case here.

For Android, Xamarin runs the Mono Runtime side-by-side to the Dalvik (and/or Android) Runtime.

I recommend checking out this doc:

http://developer.xamarin.com/guides/android/under_the_hood/architecture/

For iOS, Xamarin uses an AOT (Ahead of Time) compiler.

Unfortunately, I don't have a good link to send you that goes into more detail.

And if you're interested in metrics check out this blog post by an ex-googler:

https://medium.com/@harrycheung/mobile-app-performance-redux-e512be94f976

For Android, Xamarin runs the Mono Runtime side-by-side to the Dalvik (and/or Android) Runtime.

I recommend checking out this doc:

http://developer.xamarin.com/guides/android/under_the_hood/architecture/

For iOS, Xamarin uses an AOT (Ahead of Time) compiler.

Unfortunately, I don't have a good link to send you that goes into more detail.

And if you're interested in metrics check out this blog post by an ex-googler:

https://medium.com/@harrycheung/mobile-app-performance-redux-e512be94f976

Those metrics are quite flawed though, J2Obj-C(Java auto-translated to Obj-C) outperforming Obj-C is a pretty clear sign that they are comparing apples and oranges, Xamarin however does perform reasonably well on both iOS and Android as long as you stick with the native API wrappers and don't use the horribly buggy and slow Xamarin.Forms(allthough being able to share your UI code between WP,Android and iOS might make it worth the hassle to get that junk working decently).

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement