Common Type System (CTS):
CTS is basically a standard that specifies how types are declared, used and managed in the common language runtime and it is intended to allow programs written in different programming languages to easily share information. It establishes a framework that helps enable cross-language integration, enforces type security and define rules which languages must follow to ensure that objects written in different languages can interact with each other.
Now following these guidelines, C# is a very type safe language. It's strongly typed because type rules are very strict e.g you cannot call a function that accepts an integer with a floating point number unless you perform explicit conversion.
Common Language Specification (CLS):
CLS is a subset of CTS, it specifies a set of rules that needs to be satisfied by all language compilers targeting CLR. CLS are mere guidelines and restrictions that a language should follow so that it can communicate with other .Net languages in a smooth manner.
For example: C# does no allow multiple inheritance but c++ does, therefore c++ code cannot be used inside c#, because it is not a CLS compliant language.
Common Language Runtime (CLR):
The .Net framework consists of CLR plus a set of libraries. The two terms BCL(Base Class Library) and FCL(Framework Class Library) you will encounter often being used interchangeably, however there is a slight difference between the two. BCL consists of mscorlib(Microsoft Core Library), system and possibly other additional assemblies. However, it does not contain ASP.NET, ADO.NET and WinForms and other such classes/namespaces that provide additional functionality.
FCL is BCL plus everything that ships as the .Net framework. Therefore, FCL is the entire framework whereas BCL is just the core libraries.
The c# code or any of the .NET languages code gets compiled into CIL(Common Intermediate Language) which is often called managed code. And when finally CLR loads an assembly, it converts the IL into the native code of the machine. This conversion from IL to native code is done by CLR's JIT(Just In Time) compiler.
JIT compiler:
JIT compiler converts the appropriate instruction to native code for execution just before the function is called and hence the managed code or IL is compiled only when it is needed. CLR provides various JIT compiler and each works on a different architecture depending on OS. This is the reason why Microsoft Intermediate Language can be executed on different OS without the need of rewriting the code specific to that OS.
C# relationship with CLR
Technically C# is independent of CLR, however it depends on a runtime equipped with a host of features such as:
- Automatic memory management
- Exception Handling
So, it is evident that the Design of C# maps closely with the design of Microsoft's CLR which provides the above mentioned runtime features.
Above was a brief overview of all the terms you'll hear while listening to a .NET or even c# discussion. Hopefully now you'll know the meaning behind them.
No comments:
Post a Comment