How does C# fares in terms of portability these days? I checked years ago, and at the time, for non-Windows OSes you had to use Mono. But whether your application was going to work or not also depended on which graphic libraries you were using, e.g. WinForms wasn't going to work on Mono. At the time, C# was presented to me as a better Java, but to me it seemed that Java had true cross-platform compatibility while C# was going to work nicely only on Windows, unless you had some proper planning of checking beforehand which libraries were working with Mono.
Back in the day Mono had surprisingly good WinForms support on Gtk. It was never going to win awards for pretty and could never hit true compatibility with P/Invoke calls to esoteric Win32 APIs, but it was good enough to run any simple WinForms app you wanted to write for it and ran some of the "popular" ones just fine. (That old Mono WinForms support was recently donated to Wine, which seems like a good home for it.)
.NET has moved to being directly cross-platform today and is great at server/console app cross-platform now, but its support for cross-platform UI is still relatively nascent. The official effort is called MAUI, has mostly but not exclusively focused on mobile, and it is being developed in the open (as open source does) and leaves a lot to be desired, including by its relatively slow pace compared to how fast the server/console app cross-platform stuff moves. The Linux desktop support, specifically, seems constantly in need of open source contributors that it can't find.
You'll see a bunch of mentions of third-party options Avalonia and Uno Platform doing very well in that space, though, so there is interesting competition, at least.
.NET is totally cross platform these days. Our company develops locally on Windows and deploys to Linux. I’m the only team member on Mac and it works flawlessly.
If you only care about linux on x86-64 or some ARM it is cross platform. Getting .net on FreeBSD is possible, but it isn't supported at all. QNX from what I can tell seems like it should be possible but a quick search didn't find anyone who succored (a few asked). My company has an in house non-posix OS useful for some embedded things, forget about it. There are a lot of CPUs out there that it won't work on.
.NET has some small cross platform abilities, but calling it totally cross platform is wrong.
- Application development targets on iOS and Android use Mono. Android can be targeted as linux-bionic with regular CoreCLR, but it's pretty niche. iOS has experimental NativeAOT support but nothing set in stone yet, there are similar plans for Android too.
- ARMv6 requires building runtime with Mono target. Bulding runtime is actually quite easy compared to other projects of similar size. There are community-published docker images for .NET 7 but I haven't seen any for .NET 8.
- WASM also uses Mono for the time being. There is a NativeAOT-LLVM experiment which promises significant bundle size and performance improvements
- For all the FreeBSD slander, .NET does a decent job at supporting it - it is listed in all sorts of OS enums, dotnet/runtime actively accepts patches to improve its support and there are contributions and considerations to ensure it does not break. It is present in https://www.freshports.org/lang/dotnet
At the end of the day, I can run .NET on my router with OpenWRT or Raspberry Pi4 and all the laptops and desktops. This is already quite a good level given it's completely self-contained platform. It takes a lot of engineering effort to support everything.
That's still pretty much cross-platform for all practical purposes, as it supports far more platforms than most softwares anyway. After all cross-platform only means that it runs on multiple platforms, not on all possible or even technically feasible platforms. Being cross-platform usually means a much easier porting but that porting still has to be done somehow.
Weird, I opened a binary I built years ago on Windows in Mono, and it was Winforms and rendered correctly, I think you mean WPF and the later GUI techs. Winforms renders nicely on Mono for a little while now I think?
There's a lot of options, but also the latest of .NET (not Framework) just runs natively on Linux, Mac and Windows, and there's a few open source UI libraries as mentioned by others like Avalonia that allow your UI to run on any OS.
The issue at the time was having a WinForms application to run also on macOS, and IIRC at the time WinForms wasn't supported outside of Windows. Maybe Mono on Windows is still different from Mono on macOS. Anyway, the situation seem to be much better now. I'm not going to invest time into C# at the moment, since I'm in the Java ecosystem and Im currently taking some time to practice with Kotlin. But it's good to know that now C# is an option as well.
Forgot to include my OS: I ran a .NET (Framework? I think) .exe I built on Windows in 2020, on Linux with Mono and it worked and looked (aside from thematic differences) like I remembered it looking in 2024.
Now that I thought a bit more about it, I think I unlocked a memory of WinForms working on some macOS versions and not others. Maybe it was even just supported on 32 bits versions and not in 64 bit versions. One way or another, the bottom line was that it wasn't going to work on the latest macOS version at the time. But I actually tried it on Linux and it worked there.
you should checkout AvalonuiaUI[0] or unoPlatform[1] if wanting to target web/mobile/window/linux/macOS
if building for the web online, asp.net core runs on Linux servers as well as windows
and there's MAUI [2] ( not a fan of this), you are better-off with with the others.
in summary c# and .NET is cross-platform, third party developers build better frameworks and tools for other platform while Microsoft prefers to develop for Microsoft ecosystem, if you get
> and there's MAUI [2] ( not a fan of this), you are better-off with with the others.
I will say MS has been obsessed with trying to take a slice of the mobile pie.
However their Xamarin/WPF stuff left so much to be desired and was such a Jenga Tower that I totally get the community direction to go with a framework you have ostensibly have more control over vs learning that certain WPF elements are causes of e.g. memory leaks...
If you're doing ASP.NET Core webdev, it's seamless. Runs in Linux docker containers. Developers in my team have either Windows (Visual Studio) or Linux or Mac (Rider) machines.
I mean since Mono it has completely changed. They are about to release .NET 9 which is the 8th version (there was no v4 to reduce confusion with the legacy .NET Framework) since being cross-platform.
Mono was a third party glorified hack to get C# to work on other OS. .NET has been natively cross platform with an entirely new compiler and framework since mid 2016.
> Mono was a third party glorified hack to get C# to work on other OS.
Indeed, this is what I didn't like back then. Java has official support for other OSes, which C# was lacking at the time. Good to hear that things changed now.