Hacker News new | ask | show | jobs
by lanestp 3497 days ago
I've been extremely disappointed in Xamarin. The main issue is that you don't really get code sharing. I would estimate that only 25% of the Xamarin project I manage is cross platform code. The rest is this bizarre merger of native APIs with C#. It's difficult to write because of the lack of examples and documentation. It's also buggy, even with simple things like page views.

The real problem is that I can write a native iOS app in a fraction of the time it took to write a Xamarin app. Swift has improved iOS development speed so much I'm not convinced we need cross platform app engines (excluding games).

As for Android, yeah, native Android sucks. Activities and fragments are the worst idea anyone has ever had and no one agrees on best practices. But even with cross platform high levels of abstraction like Unity3D you still need to understand them. So, my current advice is to suck it up and write it native twice. Pick your favorite OS, start with that, and then port the logic.

7 comments

I've had completely the opposite experience. Have worked on several medium-to-very large Xamarin projects (4 developers up to 60 developers) and rarely have I seen code sharing drop below 50%, with the sweet spot being around 60%.

2 years ago, Xamarin was buggy as hell. Today, (IMHO) it's quite stable.

Edit: downvoted for sharing my experience? Stay classy, HN.

Don't worry about strange downvotes. Nothing attracts upvotes faster than an initial downvote. Lots of people will upvote an unfairly grey comment that they normally wouldn't have upvoted. So it's quite likely that you'll end up with more upvotes than you otherwise would have.
Can you elaborate on what kind of apps are you developing and where you are getting good reuse? My apps are generally heavy on the UI and moderate data and I'm wondering where the sweet spot is.
I've been doing Xamarin for about 6 months and I get most of me reuse in services. Sure, manipulating the UI is mostly native code but the rest can be reused such as the DB layer, API layer, and anywhere else you have business logic.
Enterprise mobility mostly; moderately heavy on UI (UI standards in the enterprise are rising, particularly for mobile users), but I generally find the bulk of reuse is in workflow, local persistence/offline storage + data synchronization + security/encryption + enterprise infrastructure integration / cloud & "other" services integration (e.g. CMSs, CRMs), etc.
I had no issues two years ago; what was buggy? We wrote very large apps in it without problems (besides the normal crap one has with builds now and then).
Can I ask the products you have worked on with Xamarin?
NDA'd, but I'm focused mostly on enterprise mobility
Does your NDA permit you to tell others that you have an NDA?

/s silicon valley reference

I will see if I can get my contract amended to explicitly permit that ;)
Hm, completely different experience here. I've been involved with three rather large Xamarin-Projects in the last year, and we were (team-wide) completely surprised at how much of the code can actually be shared, how our velocity compared to native development and the overall dev experience.

I think the code sharing thing really comes down to how you're using Xamarin – if you keep on writing apps the way you're used to from the original platforms, there's not much to gain. On the other hand adopting the patterns and ideas that influence the .NET sphere (DI/IoC, MVVM..), Code Sharing rates (or PCL vs. Native LoC) can be as high as 80/20.

Xamarin Studio certainly has its own shortcomings, but both Microsoft (Visual Studio for Mac) and Jetbrains (Project Rider) are actively improving or developing alternatives, so I think that pain is going to fade over time.

I think it's going to entirely depend on what type of app you have. Much like your parent comment, my experience with building an app was that very little code could actually be shared. In my case we had some fanciful design that would largely have to be custom code for each platform. Thinks like API calls, validation, business logic could be shared but that was negligible compared to the platform specific code.
Yes, and that's always going to be the case with cross platform development. Fancy UI/UX is going to be highly platform dependent, while projects that have more model/controller code are going to be easily shared.
It depends. I've been pretty happy with Xamarin for what I'm doing (a game [0]).

If you are using basic Xamarin then you will end up writing separate UI code for each platform, but you can still share business logic if you architect if well. Xamarin.Forms is different and lets you share the UI too.

Even with Forms, you will always have some platform specific code, but this is normally small. For example, some implementation details when using SQLite.

[0]: I'm writing about this starting with https://unop.uk/cross-platform-native-mobile-app-development...

I was extremely disappointed in the development experience, but the core technology is extremely helpful, depending on your use-case.

If your app is just a mobile front-end for a REST API then I wouldn't bother with it: develop two versions of the app with different UI idioms.

If your app does something considerably more complex, Xamarin might also be a good idea. Keeping two drastically different codebases in sync can be a very big task, but I suggest proactively looking at issues people have experienced with it, as well as other differences such as memory management which works very differently to what you're used to as a .NET developer.

However I think a number of responses have strayed from the question, which is "is it worth learning Xamarin". It appears Microsoft bought the technology because it was useful, not to kill it. I don't think the technology will be retired any time soon and can only get better. So long as Microsoft gives this the TLC it needs, it will be a formidable part of any developer's toolkit.. so long as it can get over the really bad reputation it has.

I for one will explore every possible alternative before considering Xamarin again.

"The rest is this bizarre merger of native APIs with C#. "

That was the thing that struck me the most when following a Xamarin course. I just don't see the added benefits of Xamarin when you are at that level of using (or having knowledge of) native code.

The UI Code(The stuff that uses these apis) should be a thin layer ontop of the core app.
I've gotten great levels of code-sharing, but you don't just get it out of the box. You really have to architect for it. See: MvvmCross and ReactiveUI.
You can do all of that with Forms with custom renderers when needed. I like that flow; mock up the app with standard cross platform components and when the basic functionality is in place, add custom renderers to add fancy UI.
> I would estimate that only 25% of the Xamarin project I manage is cross platform code.

Yep, you will keep hearing this from people complaining of Xamarin. A huge problem indeed, and I'd say enough for it not be worth learning.

Vs what? Native would be the same? And with native you have different languages. So which cross platform gives you that but with more code sharing? 25% (which is low, we are well over 60% in general) is more than 0% and you can work in F# to boot.