.Net, Azure and occasionally gamedev

Recap on Xamarin.Forms

2017/12/09

I've now finished four apps (and created at least a dozen prototypes) with Xamarin.Forms so I feel its time for a recap.

The overall experience was.. subpar to say the least. In my opinion Xamarin Forms is still very much in alpha and not really ready for production.

Here's a few points why:

Startup time is abysmal

That Xamarin isn't fast at startup (esp. on android) has been known for a long time, however Forms is a lot slower to startup than Xamarin Native and it makes for a very bad user experience when a small to medium sized app takes 4-5 seconds to start on a latest gen high-end phone and 6-8 seconds on a 2 year old phone (considered high-end back then).

Error handling

That different platforms require different error handlings isn't anything new, however with Xamarin (esp. with the latest series of updates that where provided) a lot of error handling seems to be delayed to runtime.

I.e. on a clean Windows install I setup Visual Studio with all tooling, but forgot to download "Android SDK Build-tools v27.0.2" from the SDK Manager.

Xamarin worked just fine (using an older build tool chain) in debug mode and even happily compiled in release mode without any errors. However once deploying the release version to an actual phone the app would insta-crash on startup. I still don't really know why the new toolchain is required or why it worked fine in debug but failed in release mode with the older toolchain.

Bugs, bugs everywhere

The various bugs are well known and I have yet to see a company (that is developing with Xamarin) that doesn't have a "giant list of Xamarin bugs & workarounds" list.

Often times it's small things that sort of work on all platforms, except sometimes they don't on some platforms:

Overall this makes for a frustrating, hair pulling developer experience.

Lists, anyone?

Can we talk about lists for a moment?

Sure, Forms has a listview and even a few basic templates to demonstrate it's flexibility (ImageCell, TextCell and the like), but.. beyond that?

If I want a list that shows two images next to each other (and the images aren't always the same height) I'm shit-out-of-luck and have to resort to hacky manual bindings setting each itemcell's height manually to the taller image height.

Except I can't even get the image height from an image loaded from the web so I save the image to disk and then load it again... err okay.

Controls

Overall the experience with controls has been a very flaky one. Controls sort of work, except for when they don't or show different behaviour across platforms.

Once you actually get them to behave sort of as expected you realize: the entire control set is very limited and it is near impossible to build native looking beautiful designs because only the very basic controls have been provided.

Forms seems to be targeted more towards internal business applications ("hey lets build an app for our upcoming conference").

Productivity gain (hint its actually a loss)

One big argument for Xamarin.Forms is the productivity gain of sharing Xaml across platforms and "build once, run anywhere").

In theory you only have to write business logic once (no more different bugs in different platforms!) and write the ui layout once.

In the real world it's actually a productivity loss. The entire toolchain is just not ready for primetime and I'm definitely spending more time chasing weird bugs and unexpected behaviour.

Even when I get the layout to behave as necessary I always find subtle differences between platforms.

To make matter worse most of the time small differences between platforms are necessary (iOS has a different navigation model compared to android) so now I have shared views but I actually need to make them look different again!

At least Xamarin provides "On Platform" which allows you to specify code/xaml that only executes on a specific platform.

This is enough to add e.g. different colors for different platforms:

<OnPlatform x:Key="SwitchOnColor" x:TypeArguments="Color">
  <On Platform="iOS|Android" >#0000FF</On>
  <On Platform="UWP">#FF0000</On>
</OnPlatform>

Is Xamarin Forms really the holy grail? I don't think so

Stepping back and looking at the bigger picture, I don't think that Xamarin Forms will be the primary way of app development for any company.

Internal business applications that need to be rolled out to all employees of a company and have to work and not look pretty? Sure. Maybe.

But everyone else is much better off with Xamarin.Native where you can share the code but let designers create truly native UIs.

Sure, the idea of sharing 100% (more like 90-95% in real world scenarios) of code sounds sexy and "could lead to faster app development cycles", except that it really doesn't work in the real world:

tagged as Xamarin.Forms and Cross platform