Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I heard almost all parts of Windows are written in C and C++ with some assembly. Why did Microsoft skip C#? Is there any scope for C# in the development of future Windows versions?

share|improve this question

closed as not constructive by tdammers, gnat, BЈовић, Martijn Pieters, World Engineer May 4 '13 at 23:34

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
C and C++ compile to assembly. C# compiles to bytecode for the CLI. This bytecode and virtual machine abstraction prevent it from being useable as a language to program an operating system that needs to talk to the hardware directly. Whine in theory, one could write a C# compiler to assembly, the abstractions of the hardware in the associated runtime would still be there making it unsuitable. –  MichaelT May 4 '13 at 19:49
    
@MichaelT I thought Windows accessed the hardware through the HAL? If this is the case then the only code which would need to be processor-specific is the HAL itself. –  PeteH May 4 '13 at 20:33
    
I bet they will use Java. Oh and since I am an oracle, I therefore predict they will also rename company to Oracle –  gnat May 4 '13 at 20:54
1  
@gnat Microdeck but it won't happen till 2029. Speculation about future actions of organizations or individuals is not constructive. Have a pleasant day. –  World Engineer May 4 '13 at 23:35
    
@MichaelT: C, C++ and C# don't compile to anything. They are programming languages. Programming languages don't compile, compilers do. There are compilers for C and C++ that compile to JavaScript, JVM bytecode, CIL bytecode or LLVM bitcode, for example. There are even interpreters for C and C++. On the flipside, there are compilers for C# which compile to native code, there are also compilers which compile CIL to native code. In fact, there is no implementation of C# in actual use today that does not eventually compile to native code. –  Jörg W Mittag May 6 '13 at 11:24

4 Answers 4

C++ gives you access to the underlying hardware, something C# can't provide. So for the foreseeable future, Windows will be built in C++ (as parts as still built in assembly where raw performance and interrupt handling are necessary).

As a proof-of-concept, Microsoft Research built Singularity, a C#-based operating system. It uses a superset of C# called Spec# and some other extensions to minimize the need for C++ and other lower-level languages.

share|improve this answer
3  
of course minimising the need for C/C++ could also be written "still has to use C/C++". –  gbjbaanb May 5 '13 at 13:46
    
@gbjbaanb: The only reason why Singularity still uses C++, C and assembly in parts of the OS is that the OS was being written while Sing# was being designed, and the parts of Sing# that would have been needed to write, say, interrupt handlers hadn't been designed yet when the interrupt handlers were being written. Now that the features are there, one could re-write those parts in Sing#, but Singularity is a research project: showing that it could be written in a managed language is enough, you don't have to actually write it. That's the difference between engineering and research. –  Jörg W Mittag May 6 '13 at 11:21
    
Another big chunk of C++ code in Singularity is the debugging interface, which is in C++ only because it was basically copy&pasted from Windows and .NET, so that the Singularity team could re-use the existing debugging tools. –  Jörg W Mittag May 6 '13 at 11:26

In direct answer to your question, I bet you'd find that most of Windows pre-dates C# in any case.

Who's to say what will happen in the future? I've seen so many revolutionary ideas from MS over the last 25 years that I've lost count.

But I read somewhere that VS2012 (the gui at least) was entirely rewritten in C# and WPF, so maybe you could take that as a sign of future direction? But I wouldn't put money on it.

share|improve this answer

Not working in product development but clearly microsoft windows for good years will still be developed in C and C + +. This is because the languages ​​allow / provide access to hardware to a safe level instruction. C # runs on MSIL and has no goal of being language OS.

share|improve this answer
1  
C# does not "run on" MSIL. C# and all the other .NET languages are compiled to IL, which is basically a hardware-agnostic assembly language. And of course it is also entirely possible to target IL using the C++ compiler, as well. IL is then compiled (JIT or ngen) all the way to machine code for the hardware it is running on. The resulting machine code still has a dependency on the .NET runtime, of course. As of Windows Vista it was possible to write Windows device drivers using C#. So, parts of the OS are in fact written using .NET, but it seems unlikely that the HAL will ever be .NET. –  Craig May 5 '13 at 23:00

At the time, there were no serious competitors to C/C++ in systems programming and now it's a legacy codebase that would probably cost a lot to port. C# also did not exist back then. For the record, there are attempts to turn .NET into an OS platform but these are not Microsoft projects.

share|improve this answer
    
There's also a Microsoft attempt called Singularity: research.microsoft.com/en-us/projects/singularity and en.wikipedia.org/wiki/Singularity_(operating_system) –  rwong May 4 '13 at 23:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.