In the Previous post, tried to touch upon the .NET Ecosystem and its different variants and how it provides the core development support for the Developer community...pls check out if you have missed...
In this article, presenting the basic building blocks that make up the .NET Framework in detail
As Humans we need language to communicate and that’s true for the world inside machines and there should be rules/specifications defined, so that developers can follow them and make the information flow in a meaningful way through applications.
CLI (Common Language Infrastructure) provides the base infrastructure with set of specification/standard that defines the basic rules for creating and managing the applications and also the runtime environment that supports application execution at multiple platforms. The core components that help to perform the same,
Common Type System (CTS)
Common Language Specification (CLS)
CLR (Common Language Runtime)
FCL (Framework Class Library)
The Common Type System (CTS) is a key component of the Microsoft .NET Framework, and it is used to define and enforce rules for the data types that can be used within .NET applications. CTS ensures that all .NET languages use a common set of data types and that they can interoperate and exchange data.
At the broader level, CTS differentiates data types as Value & Reference types, which indicates the way data is stored in memory.
Value types get stored in the stack part of the memory and Reference types gets stored in the Heap part of the memory and there are reasons to it... (More on stack & heap in my later article)
What are some of the common Rules that CTS mandates?
- Any types declared in .NET languages need to fall under (either Value/Reference types). So, it gives the power to .NET to handle manage, store and execute according to its boundaries and make it strongly typed. All these types can be traced back to System.Object in .NET. (User defined classes are not inheriting directly from System.Object, but it is an implicit inheritance that the CTS handles)
- CTS does not allow types to inherit more than one base type.
- CTS also defines rules for operators such as (arithmetic and comparison operators), which can be overloaded and used with different types.
- CTS defines rules for generics (to create type-safe collections), rules for interfaces (to define properties and methods), rules for enumerations, exceptions & nullable types
Below sample shows the usage of primitive types in 2 different languages (C# & VB.NET) and how CTS defines base types and organizes it in root System namespace.
The Common Language Specification (CLS) is a subset of CTS, and it ensures that all the.NET Framework languages can interoperate and exchange code between them.
CLS rules are more of how the languages implement specifications. Some of the common CLS rules are as below,
All languages must support the CTS, which defines a set of common data types.
All public methods and properties must use only CLS compliant data types, which are data types that are defined by the CTS and are supported by all languages.
All languages must support exception handling and must use the same mechanisms for throwing and catching exceptions.
All languages must support interoperability with other .NET languages and must provide mechanisms for calling methods and properties defined in other languages.
Does all .NET languages support CLS Rules?
Hmm...there are languages which are CLS Compliant (C#, VB.NET), and some are not (F#,IronPython), but since all these languages fall under.NET Framework, they can interact with each other. However in some cases, the Non-Compliance issues might arise during cross integrations and those issues need to be handled by the developer on case-by-case basis(like in some cases follow compliance rules, or opt for conversion route or hybrid of both)
*Does it seem CTS & CLS overlap? *
There is always this confusion on the overlapping of the CTS & CLS, but in broader view, the CTS defines a comprehensive set of rules for defining and using types in code, while the CLS defines a more limited set of rules that all.NET languages are required to support for better interoperability.
Then comes the FCL (Framework Class Library)- main staple for the day-to-day activities of a.NET developer, is a set of libraries and APIs that cover various domains and functionality, such as data access, networking, security, and user interface. some of the commonly used libraries
Check through the below URL for complete list of libraries supported by.NET
.NET FCL
Finally, the execution engine of the .NET Framework - CLR (Common Language Runtime).It is responsible for executing.NET applications and managing their runtime environment. The CLR provides services such as memory management, security, and exception handling, and it is responsible for enforcing the rules and conventions defined by the CTS to ensure that programs run safely and without causing unintended effects.
So once the developer generates the binaries intended for specific machine architecture (x86/x64) it can be used in the target machine for execution. So, in any client/target system, the .NET Runtime Framework needs to be installed to execute the binaries.
As more applications are migrating/already migrated to Cloud and Docker based systems, where-in compilation, deployment and execution are so modularized/containerized, this article here only tries to give an insight on how the.NET framework handles it for all standard.NET applications.
It might be that you have chance to develop Standard.NET applications or migrate them to newer designs or possibly creating compilers or more in-depth work on Framework, knowing the building blocks could help to drill down core specifications to build newer systems.
Let know of your comments/suggestions!!!
Top comments (0)