59 points · by vanilla-almond · 4y ago · 86 comments
For example, Electron is often discussed on HN (liked and disliked), but .NET is far less discussed as a cross-platform option.
Similarly, Xamarin is a platform built on top of .NET for building Android and iOS apps (using one codebase). This sounds like the holy grail of mobile development. But what is the reality?
I did a search on HN and found no stories about Xamarin from the last year. The top search results are HN stories from 5-10 years ago. This makes me wonder how popular .NET is for cross-platform desktop or mobile apps.
What has been your experience using .NET writing cross-platform desktop and mobile apps?
"not even Microsoft, literally the people who own Xamarin, use it in any of their big products like Teams, Outlook, and the list goes on. Instead, they reach for native development or Electron. So we can just tie a bow in it and have a minute's silence for another end-of-life cross-platform software development framework."
"None of These Problems Are Solved With MAUI. The poor developer experience, how apps look, XAML being a pain, and these other core issues won’t be resolved by MAUI. So, if you already know Xamarin Forms, and you’re waiting for MAUI to land, but you’re not 100% thrilled with the experience so far, then it’s a great opportunity to think about learning something else."
Source: https://betterprogramming.pub/xamarin-forms-is-dying-and-mau...
A Xamarin app doesn't need to use XML or Xamarin Forms which provides UI components. A totally custom interface/game can be developed with Xamarin + SkiaSharp which provides drawing primitives.
Doing stuff with Skia on MAUI at least is tricky because there is no concept of a mouse, so good luck creating a hover effect on your button.
Teams Mobile apps are native and built while Xamarin existed; not using Xamarin.
Rewriting the history as if Xamarin was an option from the beginning is disingenuous.
Main reasons were:
- You can use Xamarin.Forms to write cross-platform UI, but our UI was complicated enough (a weather app with lots of custom UI) that Xamarin.Forms would not have worked for us. So we still needed to write 2 separate UI codes, which Xamarin allows for because it exposes the complete SDKs for both platforms via Xamarin.iOS and Xamarin.Android.
- Xamarin provides a way to use existing 3rd party libs written in native iOS/Android by creating "bindings". For very popular libs, the Xamarin team maintains these bindings, for others, you need to rely on open source ones. The client required us to use a bunch of third party libraries and we either couldn't find them at all, or found ones that didn't work. We needed Mapbox, Firebase analytics & Crashlytics, and some other ones... pretty well-known libraries.
We were in contact with someone at Microsoft during this exploration and even they couldn't help us. They couldn't point us to any big well-known names using Xamarin and they couldn't help us with any of the missing or broken bindings we needed.
Thankfully in the end we just split up into 2 teams and wrote the app in native iOS and Android.
When you have millions of users, that's definitely the right call.
Actually it wasn’t - MAUI wasn’t released until May 2022, tooling was just released July 2022 for Windows, and VS for Mac with proper support has yet to be released. If you’re used to command line that may not seem like a big deal, but the whole point of the .NET ecosystem is that you have a rich set of tools that saves time and enhances developer productivity.
So as for why Xamarin wasn’t discussed for the last few years, it’s probably because Microsoft put it in a coma for 2 years.
I was hoping MAUI would fix a lot of the quality issues, but like any big rewrite, it seems to have traded one set of problems for another. The developer experience is better, but there are lots of bugs in basic functionality that make it difficult to use. https://github.com/dotnet/maui/labels/t%2Fbug I don’t think Microsoft has enough engineers assigned to this project to make it successful.
If you don’t care about the quality of your app (e.g. your a corporate form developer and don’t care about your users) MAUI is a great choice. But if you don’t care about the UX, web technologies are almost certainly a better choice.
As for native desktop, you’d have to be really stupid to choose WinUI or UWP, unless the point of the app is to be a WinUI or UWP demo. WPF is fine, but then why on earth would you choose that over electron or WebView2, which solves some of the resource problems from pure electron.
All of this is coming from someone whose entire career is built on .NET client technology… I was really hoping (and still hope) for a turnaround. I bet big on Xamarin being the right approach; I still think it is, but Microsoft really dropped the ball since the acquisition.
For the cross-platform stuff (mostly deep learning demos with UI) I use Avalonia because it supports Linux.
Based on the .NET Rocks podcast, it sounds like Blazor is the new WinForms.
Given the situation with Windows, I don’t see it being a great choice for a monoplatform app (unless that app is a game) - chrome books and Mac are getting more popular, and web works everywhere.
* iOS
* Android
* PC
* PlayStation
* Xbox
* VR
Rec Room is a "game for building games". I'd say Unity has worked pretty well. Given that the product is a game this success with single-lang cross platform may be more common than other industries. Still, though, I'm surprised that there isn't a similar "engine" for non-game cross platform development like Unity or Unreal that folks are generally happy with.
(Shameless plug, we are hiring if folks are interested https://recroom.com/careers)
If I was Microsoft I would just fork Flutter and add C# support and call it a day. Flutter is really flexible for mobile and desktop and has a ton of community support with libraries.
IMO, the source of the problem was that it's widgets used native widgets for rendering. Build-in widgets were lowest common denominator, primarily supporting only features avaliable on all platforms. Where platforms deviated, complexity started.
However, UI frameworks that render widgets themselves, using drawing APIs, are a completely different story. They are harder to create, as they need to develop all widgets from scratch (rendering, text, input, accessibility etc). Basically reimplementing part of OS APIs. But once this is complete, the hard part is done and supporting additional platforms is relatively simple. Avalonia has written good blog post about this: https://dev.to/avalonia/avalonia-platform-support-why-its-si...
Developing cross-platform GUI application with this kind of frameworks is about as complex as developing GUI application using native SDK for a single platform. Most complexity doesn't result from different platforms anymore, but from different form factors and input devices.
They have one Achilles' heel however. The web. HTML is unfortunately much higher level that drawing API on other platforms. So, the only option for the web is usually WebAssembly.
* Easy to get started
* Builds for iOS on a remote Mac but runs in local emulator
* Performant!
* Simple to write device specific code
* Power of .NET
* Supports more than Android and iOS, like desktop UWPWe still just do the web app thing. For our business & customers, this is the lowest-friction way to deliver the application experience. So, we are effectively cross platform on both our client and server. We only have to maintain one code pile to make it all happen.
If you can figure out a way to make the web work for you, try it. Having an app icon on someone's phone is such a ridiculously wasteful thing to chase unless you can properly justify it.
Webview apps are still being accepted by the App Store. They don't care what tech you use to build your app, as long as it provides functionality.
It’s all about functionality and UX, not about technology.
Re-developed in Xamarin.iOS in 2016 which has been a solid decision due to the productivity gains I get from C# and Visual Studio tooling.
Xamarin.Forms works well for line of business apps and the performance with iOS was fine, however encountered a number of Android performance issues which is simply due to the nature of the framework.
If I would start something now I would most definitely go for Swift/SwiftUI and Kotlin/Jetpack Compose. I find that productivity, developer experience are best with those as soon as one gets the hand of them.
Also, these are the only ones to be guaranteed to be around long-term. While any of the cross platform options sound interesting, there is no guarantee they will be around.
The motto for Xamarin used to be "you can do all the same stuff you can do natively, with day one support". Not anymore, and it's disheartening to see.
I noted down the following technologies to be the next thing to learn / take a look at:
* MAUI + Blazor Hybrid (no official linux support, which usually is a no go for me)
* AvaloniaUI (looked very promising, especially the 11 Preview1[1], although not microsoft)
* Uno Platform (also not bad but not from Microsoft...)
I thought, it would just be a matter of "which one is the best", but it seems that all these did not come to stay or do not have official support from Microsoft (which usually means not getting widely adopted).An AvaloniaUI example App named Camelot[2] looked good at first, but after testing this on different OSes made me think, that performance wise there is a lot of room for improvement.
So far i have given flutter a wide berth because learning a new language (Dart) AND a new framework did not seem to fit my time capacities, but what I've read here makes me think, that even writing a simple cross platform app it is not worth the effort learning another C# UI technology, because they mostly get abandoned before they really mature.
My personal conclusion: Use Flutter instead! Am I right?
[1]: https://dev.to/avalonia/turning-it-up-to-11-34jn [2]: https://github.com/IngvarX/Camelot
Performance wise Flutter too has room for improvement. Although, I don't know how Flutter's performance compares to Avalonia.
Flutter, being young framework itself, is probably more mature than Avalonia, Uno or MAUI. Also, Flutter has very good documentation and learning materials and bigger community.
When I'm working with Flutter I do miss more powerful C#, but I for sure don't miss XAML.
MS frameworks:
- MAUI (ex Xamarin.Forms) which is similar to React Native as it's controls use native widgets for rendering.
- MAUI Blazor which is similar to Electron and Tauri as it uses web view to render widgets.
- MAUI.Graphics.Controls (experimental) which is similar to Flutter as it uses Skia to render it's controls.
Non-MS frameworks:
- Avalonia
- Uno
Both Avalonia and Uno are similar to Flutter as they use Direct2D, Skia, etc for rendering. Quick comparision I just found: https://github.com/robloo/PublicDocs/blob/master/XAMLFramewo... Note, that it's already a bit outdated as Avalonia 11 is adding support for mobile and WebAssembly.
Avalonia was more focused on desktop (Windows, Linux, macOS) until recently. Android, iOS, WebAssembly is still in preview. However it does support embedded platforms, like Raspberry Pi, Torizen. It's also able to run without a desktop environment. https://dev.to/avalonia/turning-it-up-to-11-34jn
Uno I think was more focused on mobile in the beginning and expanded from there to other platforms.
All of these frameworks are build around XAML. There is some support for using C# instead of XAML, but most docs/examples are for XAML. Search 'C# Markup' for more more details.
Linux desktop is a insignificant dwarf compared to the forementioned. It's also super fragmented (what is linux desktop anyways?) and hence a ton of work to have something reliable working there. It's easy to understand why it has not been included as a first-class citizen for MAUI.
dotnet core is also open source and runs perfectly on linux, but again -- desktop no bueno.
It was great, until it became terrible.
Nowadays I don't develop mobile apps anymore. Last time I checked, Xamarin Forms was half decent to build simple apps, but you have to be pretty flexible on the specs and the visual design.
Still, for data entry apps and other simple purposes, it can be fine.
But I'm becoming more optimistic with the introduction of Blazor Hybrid. Whether you're using MAUI for mobile & desktop, or WPF/WinForms for just desktop, Blazor Hybrid provides you a web view that enables usage of Razor components made of C#, HTML & CSS. These components run natively, not in the browser.
After using Maui + Blazor with Tailwind for styling in a recent side project, I can see this becoming a viable alternative to Electron.
Personally I've not run into any big issues like that; although my work laptop is pretty beefy, I did my side project on an old laptop that can't handle really large .NET solutions (e.g. crashes every 10-30 seconds simply navigating the Roslyn codebase...), but it did okay with Maui + Blazor Hybrid.
Alternatively, I think it's possible to use vscode if you're friendly with the dotnet cli, but I had trouble getting the workloads to work correctly and didn't wanna fuss with it at the time.
The UI story is .. less encouraging. I'm not sure a UI that's both cross-platform and native-compatible is even possible. Microsoft have a load of offerings none of which anyone is really happy with.
I think the main way of building a cross-platform app in C# is not Xamarin but Unity...
However, right now I’m actually writing a simple GUI app in Godot (the game engine), because it is the closest thing to Delphi/Lazarus that I can actually be productive in…
The only app I know of using it is Bitwarden[1]
[0] https://docs.microsoft.com/en-us/dotnet/maui/what-is-maui
It was a very frustrating experience in the early days, but as MAUI has matured it's now a pleasure to work with. It is not as feature rich as some other frameworks, but it fulfilled our needs.
Uno is another cross platform C# gui framework. I gave up on C# gui apps before I ever tried it out, but it looks good.
Keeping up Cross-platform framework updated with the changing OS versions is difficult.
Preference would be to use Flutter (Google) or React Native instead of Xamarin.
Things like VSCode, github or azur pipelines are ok because the cost of a potential migration away from them is tiny compared to the benefits they bring.
However, basing your entire code base (e.g: with .Net), dev env (e.g: codespaces) or infra (e.g: azur cloud) on their tech is betting that a company with a terrible track record will never, ever, go back to its previous bad practices.
I'm not making that bet.
Things have worked just fine for me, though I haven't made anything too serious with it yet.
However, if you go outside of what Microsoft offers directly, there's many options, some of which do something similar to Electron. Two off the top of list is the Uno Platform and Photino. There's others. They come and go.