The question I always wanted to ask and was afraid to, actually - what language is .NET Framework written in? I mean library itself.
It seems to me that it was C and C++ mostly. (I hope Jon Skeet is reading this one, it`ll be very interesting to hear what he thinks about it)
-
1Download the source and find out: referencesource.microsoft.com/netframework.aspx– Michiel van OosterhoutNov 18, 2010 at 21:52
-
@michielvoo your link died, updated would be appreciated.– AelphaeisJun 18, 2014 at 15:13
-
4@Aelphaeis It's now just referencesource.microsoft.com– Michiel van OosterhoutJun 18, 2014 at 18:44
5 Answers
The CLI/CLR is written in C/C++ and assembly. Almost all of the .NET framework classes are written in C# > compiled to IL, which runs in the CLR. If you crack open a framework library in Reflector, class, you may see an attribute such as [MethodImpl(MethodImplOptions.InternalCall)] which delegates the call to the CLI.
-
11Please note that this only applies to Microsoft .NET. Other implementations of the CLI may be architected differently. E.g., in Mono a lot of the stuff that is written in C/C++ in Microsoft.NET is actually written in C# in Mono. Also, there are metacircular implementations, both by Microsoft Research and other organizations, that are written entirely in C#. Aug 25, 2009 at 14:30
-
Jörg W Mittag - Thanks, didn't know that. Will have to take a look at the C# implementations. Aug 25, 2009 at 17:10
-
1This is basically stated in StyleCop's History, if anyone wants a reference cited. Apr 3, 2012 at 14:26
-
3What is "C/C++"? You can't even suggest that you meant "C and C++" this time, otherwise you'd have written "C/C++/assembly". Sep 26, 2014 at 17:00
-
1@bigown: Bartok, for example. Note, I did not say that there are CLR implementations written C#. The CLR is written in C++. However, the CLR is only one of many implementations of the CLI VES. There are other implementations of the CLI. Bartok is a static compiler from CIL to native code plus a runtime (including garbage collector), all written in C#. As such it is very much unlike the CLR (which is also a compiler but a dynamic JIT, not a static AOT), but it is still an implementation of the full CLI, including but not limited to CLI VES, CLI CIL, CLI libraries and so on. Jul 1, 2015 at 23:27
.NET was fully written in C and C++ because the base was in assembly language. Integration of assembly with C is much easier compared to newer languages.
Microsoft .NET Framework is divided in to many segments.
CLR: C++
IO/Signal Processing: Assembly
Baseclass Library: C#
System.Threading: C#
Complex Data Structure: C++
Example: GetHashCode
There are parts of the .NET Framework that are open-source, like ASP.NET MVC, and it's written in C#.
Since the .NET Framework represents many assemblies, I'd presume that different libraries are written in different languages. As long as the language is CLR-compliant, it can be used to build parts of the framework.
All said, though; I'd assume the lion's share of the .NET Framework is written in C++ and C#.
CLR / Compilers - Visual C++
Baseclass Library - Simple Managed C (SMC)
http://blogs.msdn.com/b/jasonz/archive/2007/11/23/couple-of-historical-facts.aspx
-
3From that article: "We actually wrote the original BCL in SMC. It was a leap of faith to convert to C#". So the .NET Framework BCL is actually C#– SuamereAug 10, 2017 at 20:02