Solved How well is C# supported on FreeBSD ?

Recently, I believe at the end of 2024 C# 13 was released.
I know that C# is part of .NET.
However .NET on Windows is not the same as .NET on FreeBSD, I think.
Since the .NET implementation on FreeBSD is based on mono, if I am not wrong.
Putting the fancy things aside, how well are the core language features supported in terms of syntax ?
If C# 13 for example is not well supported, then looking at the features in version 13 at this point of time wouldn't be relevant for FreeBSD, I think.
 
If C# 13 for example is not well supported, then looking at the features in version 13 at this point of time wouldn't be relevant for FreeBSD, I think.
One tip I can give is don't always aim for using the newest features of a language. Consider them simply as extra dependencies, in a bad way. They reduce the overall portability of your software.

So, unless you *truely* need them, instead I would recommend analyzing a number of different platforms, work out the most reasonable "lowest common denominater" of C# VM available and target that.

I believe coreclr is a work in progress for FreeBSD but its not in ports yet. It also doesn't provide ".NET". Its weirdly more akin to Rotor from 2002.
 
Fellow Microsoftie here ;)

In my opinion FreeBSD can actually provide a much better "Windows server" than Windows itself does. For starters: it doesn't require any expensive licenses!

However .NET on Windows is not the same as .NET on FreeBSD, I think.
Since the .NET implementation on FreeBSD is based on mono, if I am not wrong.
First... fun fact: the .NET infrastructure is actually also an open source project. And one which also found its way onto FreeBSD through lang/dotnet. This setup 'powers' shells/powershell and I hope you know what that means!

Next part, yups, it's like you said: lang/mono5.20 is a big part of this. In addition don't forget about www/mod_mono as well: the perfect solution if you want to work with ASP.NET (which is often build upon C#.NET).

Seriously: I rely on Apache/mod_mono + Mono to host my own ASP.NET powered websites, build right with Visual Studio 2022 community. Works like a charm, and it's even more robust than IIS (IMO anyway).

Putting the fancy things aside, how well are the core language features supported in terms of syntax ?
Well, I'm not an expert (!) and I'm also convinced that it's not fully one on one. But so far I never had issues with building stuff in VS, moving that onto my FreeBSD server and then using my code there. Disclaimer: I mostly do this with ASP.NET and not so much the commandline.

However... ever since I discovered that I could run PowerShell on FreeBSD as well I actually started building some (dedicated) cmdlets for it, and so far... so good. Though in all fairness it's not much of an example because I haven't tried digging deep into system processes yet.

If C# 13 for example is not well supported, then looking at the features in version 13 at this point of time wouldn't be relevant for FreeBSD, I think.
The latest & greatest has always been an issue when it comes to 3rd parties. Same applies to ASP, I never relied on the latest standards just to be sure that I wouldn't run into hiccups right away.

But considering the fact that Mono is actually sponsored by Microsoft these days as well as actively supported (not to mention having become a part of the .NET infrastructure itself) I think it's fair to say that you can put some level of trust into it.

Yet why would it have to be the 'latest and greatest' though? I guess this also heavily depends on what you plan on doing, and yah... that depends on context.

Hope this can give you some ideas, but yeah... I'm not kidding when I say that FreeBSD is also one heck of a "Windows (support) server" for me.
 
Putting the fancy things aside, how well are the core language features supported in terms of syntax ?

Support for corporate controlled languages more or less need to be sponsored by the corporations themselves; C# (Microsoft), Java (Oracle), Swift (Apple), etc. Some people have attempted to port Java and Swift to FreeBSD, then gave up due to the amount of work involved.

Community controlled languages (Python/PHP/Perl, Go, C/C++, etc.) tend to naturally lend themselves to other open source communities.


edit: err.. we jave OpenJDK on FreeBSD. Nevermind.
 
So, unless you *truely* need them, instead I would recommend analyzing a number of different platforms, work out the most reasonable "lowest common denominater" of C# VM available and target that.
It is not that I really need the brand new features, as I am mainly learning C# between version 9-12, if I am not wrong since not every feature has a corresponding version attached to it, but the material targets C# 12 officially.
Some features like the top-level statement, if I called it right which omits the main method, and creates one implicit in Program.cs really helps in maintaining a clean code.
Or file-scoped namespaces.
Well, since I am using dotnet 8 for now, it should actually be fine.
Ryujinx targets .NET 8, luckily so, I don't really need the shiny new things.

First... fun fact: the .NET infrastructure is actually also an open source project. And one which also found its way onto FreeBSD through lang/dotnet. This setup 'powers' shells/powershell and I hope you know what that means!
Since 2007 I think .NET became open-source ?, I am not sure though.
ChatGPT, although it should be used with care, told me something like mono being the default runtime, but since .NET 5 there are unofficial versions of .NET even with support up to .NET 9 now.
Judging from the powershell, I can tell .NET can be considered to be usable on FreeBSD.

Well, Silk.NET a graphics API binder, should also work on FreeBSD according to chatGPT, with some minor tweaks.
 
It is not that I really need the brand new features, as I am mainly learning C# between version 9-12, if I am not wrong since not every feature has a corresponding version attached to it, but the material targets C# 12 officially.
Some new features are of course a benefit (which is why they are created! ;)). If this is the case, perhaps check out the preprocessor directives. It alows an out-of-band way to conditionally compile code depending on the language version available. Of course, this means you need to implement things twice, the new, convenient way *and* the old, fiddly way. So its usefulness is also something to consider.

(also note that C# has an annoyingly limited preprocessor compared to C. So much so that I would consider passing it all through cpp or m4 anyway.... but this is admittedly very non-standard)
Some features like the top-level statement, if I called it right which omits the main method, and creates one implicit in Program.cs really helps in maintaining a clean code.
Or file-scoped namespaces.
An example fallback for this would be to add a Main() in preprocessor directives. But I guess that also defeats the purpose.

Since 2007 I think .NET became open-source ?, I am not sure though.
ChatGPT, although it should be used with care, told me something like mono being the default runtime, but since .NET 5 there are unofficial versions of .NET even with support up to .NET 9 now.
Yeah, its a bit fiddly. Mono and DotGNU were big players back when .NET was "cool". Then DotGNU died and Mono was controlled by Xamerin (same guys behind Gnome I think). This then found its way into Microsoft's portfolio.

I recall Unity3D took a really old version of it and maintained it independently due to license changes around then. I was so sure Microsoft was going to buy it (as part of their strategy to purchase the "job portfolio" market).

But I am really not a .NET guy so my analysis of the ecosystem is limited.
 
Back
Top