Ask HN: Are you using .NET to write cross-platform desktop or mobile apps?
Microsoft's .NET is an open-source platform for building desktop apps and mobile apps (and more) using C#, F# and Visual Basic. Does this sound too good to be true?
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?
88 comments
[ 0.31 ms ] story [ 164 ms ] thread"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.
Teams is trying very hard to make itself a platform, and it supports telephony in a way that other chat apps don't. I can be reached on my work Teams account via a dedicated phone number, and the account includes a bunch of Viva applications and pretty deep integrations with Office, SharePoint, and Power Platform.
They do have a React version on WebView2 that is (supposedly) much better, but it's only for personal accounts right now, though that could change [1].
Thankfully their internal API is fairly self-documenting, so I've been looking into creating my own Teams client if you're interested [2]. We'll see if it'll have been an effort in vain depending on how well Microsoft Teams 2.0 goes.
[1] https://www.techradar.com/news/a-new-generation-of-microsoft...
[2] https://blog.opercom.co.uk/posts/news-13-08-22/
thanks for the link, looks good. styling and eye candy can be added later. first i think it just needs to be optimised for low memory and speed - not using react is a good step in this direction.
I threat the main process as a backend api and use ipc as a broker between that and the ui. The renderer process does nothing but show text and icons. From that point on one can have fun with threads and all :-)
This argument is weak. Its not like millions of people are crammed within the app all at the same time, while integrated with AD, or other microsoft bloatware. It may impress inexperienced devs, but it's really not much of an architectural challenge. MS could have done a better job.
But to satisfy your curiosity, my background is in developing some rather large systems, used by hundreds of millions. Not these apps specifically (although they do handle large amounts of data, a lot more than teams), and it's a good indicator that I know what I am talking about and without bragging I can smell poor design and a lazy job.
I think the only inflated thing here is your ego.
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.
https://github.com/dotnet/maui/issues/3739
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.
Microsoft announced Teams March 17, 2017, with a launch date of the end of 2018 https://news.microsoft.com/announcement/teams-platform-intro...
Make of that what you will.
We 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.
* 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)
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.
Things have worked just fine for me, though I haven't made anything too serious with it yet.
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.
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.
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 only app I know of using it is Bitwarden[1]
[0] https://docs.microsoft.com/en-us/dotnet/maui/what-is-maui
[1] https://github.com/bitwarden/mobile
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.
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.
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.
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...
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.
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.
For the cross-platform stuff (mostly deep learning demos with UI) I use Avalonia because it supports Linux.
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.
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.
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.
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.
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.
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.