Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is C# Separate From the .NET Framework?

Tags:

c#

.net

I'm no newb when it comes to the .NET framework, I've been writing C# software that utilizes it for several years. However, a thought occurred to me the other day...how is C# separate from the .NET framework with keywords like lock and object? A statement like object derp = new object(); resolves to System.Object derp = new System.Object();, but System.Object is defined as part of .NET is it not? Even if it is defined in mscorlib, this means that a language feature is dependent on a library. The same goes for lock statements which resolve to calls to Monitor.Enter() and Montior.Exit(). Obviously it would be silly/impossible to write any non-toy program without using .NET features, but how can a language depend on a library that is largely written in that language?

like image 853
Rabadash8820 Avatar asked Aug 11 '16 05:08

Rabadash8820


People also ask

How do you explain C?

C is a high-level and general-purpose programming language that is ideal for developing firmware or portable applications. Originally intended for writing system software, C was developed at Bell Labs by Dennis Ritchie for the Unix Operating System in the early 1970s.

What is C language in English?

The C programming language is a low-level (close to the computer) computer programming language that was developed to do system programming for the operating system UNIX and is an imperative programming language. C was developed in the early 1970s by Ken Thompson and Dennis Ritchie at Bell Labs.

How is C used?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What type of language is C?

C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system.


1 Answers

Minimum requirement to implement a language is to have a compiler to convert the language into executable code and a runtime system to execute it. Neither were written in C#, they used C++. Using another language to accomplish this is a traditional and necessary bootstrapping step. The C language is a very common choice for a bootstrapping language, it is small and very easy to port, the approach taken by Mono. C itself had a bootstrapping language, it was B. Which was bootstrapped off BCPL. Which was bootstrapped off CPL. Which was bootstrapped off Atlas2. Gets murky before that, imagine somebody using the toggle switches on the front panel of a very primitive computer.

Once that's in place you can start iterating and improving. Like adding support for the lock keyword, a language feature you don't need to get a compiler and runtime system going. It relies on the Monitor class, still very thin today with the vast majority of its code in C++.

Rewriting the compiler into the target language is often next, took quite a while for C# but now done with Roslyn. Rewriting the runtime system might be considered although that isn't very common. Done as a incubation project inside Microsoft, the secret Midori project. Not just the runtime but an entire operating system. Bootstrapped off the Singularity project.

like image 117
Hans Passant Avatar answered Oct 12 '22 16:10

Hans Passant