4 ms·
Yes, there is no question that C# is sufficient to write an OS. However, you would need to ignore/replace the libraries that are normally used with C# applicati
by memracom 13y ago
Yes, there is no question that C# is sufficient to write an OS. However, you would need to ignore/replace the libraries that are normally used with C# applications. Instead you would write your own low-level libraries that provide only the kind of services that an OS requires. But the biggest hurdle will be the compiler. A normal C# compiler only generates bytecodes that will be run on the .NET or the Mono virtual machine engines. You will need an additional stage of compiler that either produces machine code, or something that can easily be converted to machine code such as C code or GCC's intermediate representation. It is a hurdle but not a massive one since there is a lot of support out there for writing compilers. People have recently been writing compilers for a number of languages that emit Javascript and your hurdle is no more complex.
When you write your compiler you will probably end up leaving out some C# features such as reflection, because they are too intertwined with .NET. This is common with other languages when people have tried to write a compiler that emits machine code and it does not usually cause a problem because the problem of interfacing with hardware does not demand the same features from a language as building a modern web app does.
Do your research before starting this because you will likely find a lot of projects that have already built bits and pieces that you can reuse.