How (not) to build .NET coreclr on FreeBSD

This made me chuckle. Often code from PhDs isn't always the best for long-term viability. Just check out the garbage collector alone from clr (https://raw.githubusercontent.com/dotnet/coreclr/master/src/gc/gc.cpp)
This sheer volume of over-engineered code is not really maintainable (this alone is bigger than the entirety of TCC: https://github.com/TinyCC/tinycc) and they certainly haven't followed KISS principles.
For an exercise; try getting Mono 1.0 building and running on a current platform. It will take you over a lifetime of manhours to do it. I stay away from "technology" like this.

Compare it to C where it is possible to write a compiler in about a week. Someone much smarter than me could probably even make it production ready in that time.

Even though I mentioned language names; it is the underlying platforms that I am really talking about. VB.NET and CSharp are probably fine languages but until they can drop the runtime complexity; I wouldn't recommend them. But again, that is typical of PhDs, the ideas are often valid but the execution and implementation is often atrocious (this is certainly the case for my thesis). If they can find a better (more portable) solution than a garbage collector and develop a compiler that outputs native binary from CSharp code (similar to dotgnu, unfortunately not what AOT does) then I see CSharp having a much longer life. Oh and just drop VB.NET and give us back VB[6]; it was vastly superior! ;)

I do not disagree with the underlying point you are making. But I also think that at some point, you always have to make a decision on someone smarter than you that you are going to trust. Even if you insist on keeping the bar low in terms of expertise required, at some point the sheer volume of man-hours required will turn everything into a black box for all practical purposes. So whether the black box exists because the knowledge required is so complex or specialized that you would not be able to re-implement it, or because there would be so much work to do to modify a toolchain/framework/environment that you wouldn't ever realistically have the budget for that, from a practical perspective this makes no difference, it is the same black box. So it all depends of where you arbitrarily decide to set the bar. It all depends of your risk model (which depends of your specific situation - skills, comfort zone, budget etc...).

Personally (after of course doing a risk analysis and triangulating the sanity and opportunity of investing in something both at a technological and at a strategic level), I generally speaking do not mind trusting PhDs to implement very abstract things based on sane concepts. It is usually something they do very well, and because abstract things are a common denominator, there will always be plenty of pairs of eyes and plenty of smart people enjoying optimizing these abstract problems. So I would not worry about the effort required to re-implement the VM, the compiler or such, especially since there is no reason I'd ever need to do so since I have the source code so I could keep using the same version for decades (putting aside the fact that it is unlikely there will ever be a shortage of maintainers).

Also to nitpick a little on your example, I strongly doubt that they'd over-engineer their garbage collector, this is quite a central piece of the whole thing, they are throwing a lot of resoures to extract every performance improvement possible, and I suspect this is why this file is so large as - reading their blog posts - they do not mind handling particular cases if it can makes things 5% faster. Garbage Collection, VM, and the compilers are exactly what I trust them to do best, for these are complex problems, but abstract and well understood problems. Then comes the core library, but as far as application frameworks like WCF etc... not really....

Regarding the garbage collector, they need to support plenty of use cases and customers. And a garbage collector is a very different beast than a compiler. A garbage collector is a complex optimization problem, and when we say optimize, there is the notion of "optimize for what?" (so various types of load to plan for), and how to optimize (various collecting algorithms / approaches to support - Mono even supports replacing the algorithm). So this is quite a file for sure, but this is also quite a complex challenge even on paper. And garbage collection introduces quite a lot of business value and features, it gives a lot of things for free to the developer. But whether or not (or when) runtimes relying on garbage collection are desirable is another question.
 
Regarding the garbage collector, they need to support plenty of use cases and customers. And a garbage collector is a very different beast than a compiler. A garbage collector is a complex optimization problem, and when we say optimize, there is the notion of "optimize for what?" (so various types of load to plan for), and how to optimize (various collecting algorithms / approaches to support - Mono even supports replacing the algorithm).

This is one of the exact reasons I prefer a technology to stay away from garbage collectors; they are too complex to support a number of customers use cases whilst remaining sane, elegant and portable. That said; I could rant about garbage collection for longer than I should. I note that the (default) Mono GC (based on Boehm's) is much lighter. This agrees with your suggestion to stick with Mono. ;)

I do try to avoid technology that I don't understand or cannot maintain myself but yes sometimes I do have to rely on stuff magically fabricated by smarter people. However for a programming language where if I can keep things simple I can understand pretty much the entire stack; in this case I don't see much of a reason to go with the black box when given the choice.

Professionally, within reason, I will use whatever technology gets me the most success (But not Unity or anything else involving DRM). I have worked with Mono in the past; it certainly isn't the worst XD.
 
I do try to avoid technology that I don't understand or cannot maintain myself
Decades ago, when I was learning FreeBSD and programming with C, I was complaining online about a standard library string function that didn't do exactly what I wanted. "Well, why don't you roll your own? Just look at the source, copy and modify it," said one well known veteran. That changed my whole outlook on programming.
 
I'd strongly recommend using mono for the foreseeable future rather than .NET Core.

Unfortunately, a lot of developers are switching to .NET Core and away from mono. Without .NET Core support these applications become unusable. On that could affect me:

  • Plex is a media server. It started life as mostly open source but switched to an open/closed hybrid (part of it is open source but key components are closed). My reasons for looking at alternative to Plex go beyond this thread.
  • When Plex went partial closed, the open-source parts were copied into a new project, EMBY. It too has gone partially closed-source.
  • But a new project popped up that took the last of the open EMBY and made Jellyfin. The folks behind Jellyfin re-built the core in .NET Core (instead of Mono). The result is that of the three, I can't get Jellyfin to run on FreeBSD.
It won't be the only application with this type of issue. Mono may not be going away any time soon, but if you pay attention to the .NET community, there is a definite push to move all future work to .NET Core.

Plex has an interest in maintaining some level of compatibility with FreeBSD as long as there are NAS options like FreeNAS and they want to target that as an option. The other two don't have the same interests at the moment.
 
a lot of developers are switching to .NET Core and away from mono. Without .NET Core support these applications become unusable.

This provides some pretty good evidence that things aren't quite right with the whole .NET/CLR "design". A programming language should be able to work regardless of the underlying platform. When FreeBSD moved most of the C/C++ ports from GCC to LLVM/Clang; it seems that there was a lot less breakage. And if there was breakage; it could be fixed (because it was an error in the code). VB.NET and CSharp have extremely weak preprocessors; I don't even think it is possible to write conditional code to support all types of CLR .NET VMs.
 
There is a compatibility layer, called .NET Standard. .NET Standard is a contract, an API that the various runtimes (Full .Net Framework, .NET Core, Mono) must implement precisely to avoid the kind of situation you describe. Library maintainers wanting to provide a cross-platform library program against .NET Standard. Those choosing to program against a specific runtime explicitly choose not to make their application cross-platform, usually because they want to access APIs only available on the specific platforms they target (which is not a .NET limitation but more a platform limitation).

I'm not saying everything is perfect, for example the size of the .NET Standard API has been hugely increased I think 1 or 2 years ago, probably to make it easier for libraries to target the standard rather than a specific runtime. But From what I see, library developers shoot for cross-compatibility, at the very least because they want to be able to target the Full .NET Framework in addition to .NET core. I feel they put a huge focus on cross-platform, by design this has always been the vision behind this technological scheme since the first version of .NET, but Microsoft also seem to put quite serious efforts into .NET Standard.

I think the real problem here is that your application provider is screwing you. It is as if they decide to drop Linux support because their software now runs on Mac. I wouldn't say this is a Linux issue but more an unfortunate business decision. This type of problem usually comes from the fact that people jumped on beta/alpha technologies too fast. For example, if FreeBSD support is important for their application/customers, why would they use .Net Core while there is an X year old ticket on GitHub clearly indicating that the build tools for FreeBSD are not there yet. I think this is where the issue is. They chose a tool while knowing that no compiler existed for the platform they wanted to target.

I think the problem here is not that the programming language does not work across platforms, it is rather that they chose to program for a different VM, having a different base library and using a different instruction set. But the situation was quite confusing at some point to be fair with all these renaming ASP.NET Core, ASP.NET Next, .NET Core etc.... and even disruptive changes in the developer story (tooling, file formats etc...) and APIs. But to continue to be fair, why use alpha tools for production projects? Many people do like us simply and use Mono, I do not plan to use .NET Core before 5 - 10 years. It is like deciding that you are going to build your software for FreeBSD14-CURRENT immediately (an even more unstable and risky version than 13-CURRENT).
 
Without .NET Core support these applications become unusable.
IMNSHO, then you should start looking for replacements for those applications - better find a way forward before they become unusable.
Nothing lasts forever, you have to adapt to a changing world or else you will be left alone on your isolated island of obsolete systems and stuff.

Fine if you have vintage tech as a hobby, not so fine for your day to day life.
 
IMNSHO, then you should start looking for replacements for those applications - better find a way forward before they become unusable.
Nothing lasts forever, you have to adapt to a changing world or else you will be left alone on your isolated island of obsolete systems and stuff.

Fine if you have vintage tech as a hobby, not so fine for your day to day life.

When the problem of not moving forward is lack of support of the newer framework in the OS, the OS might need to be considered as isolating itself on an island.

If you happen to know a 4th streaming media server solution that avoids .NET altogether, I would appreciate knowing about it.
 
Back
Top