Table of Contents
What Are The Tasks Performed By The Common Language Runtime? | Common Language Runtime In English
Common Language Runtime – The common language runtime manages memory thread execution, code execution, code safety verification, compilation, and other system services. These features are based on structured code that runs on the common language runtime.
The Common Language Runtime is the engine that compiles the source code into an intermediate language. This intermediate language is called Microsoft Intermediate Language, which we also know as Common Intermediate Language or simply Intermediate Language.
When you run your program, Microsoft Intermediate Language is converted to native code, or machine code, through a just-in-time compiler. When the program code is compiled, it results in a portable executable file that contains the Microsoft Intermediate language and some additional information. This additional information is called metadata.
Metadata describes the Microsoft Intermediate Language and contains details such as names, methods, signatures, and various dependency information. Common Language Runtime is another very important function. While the program is running, it manages the memory itself through a process called garbage collection.
As a result V.B. Unlike earlier versions of C#, the programmer does not need to worry about the various stages of memory management. Since the Common Language Runtime compiles your code into an intermediate language, that means you can write code in any language you want. Due to this feature of the dot net framework
This is called platform independence and is one of the advantages of the Dot Net Framework.
The Common Language Runtime accelerates your program development speed in several ways. How is this process of development accelerated, understand this-
1- When programmers write the program, they usually have to allocate and deallocate the memory of the program themselves. In dot net, the common language runtime does this work automatically i.e. the time spent by the programmers in organizing the memory is saved.
2- When you develop an application on a platform, you must be proficient in that language. When you want to develop an application on the dot net platform, you have the freedom to write code in more than one language. That is, it is not necessary that you know V.B. As in previous versions of .NET, code only in Visual Basic. If you can code in C# then you can code in this. As a result, the time it takes you to learn Visual Basic The savings are due to the common language runtime itself.
What is Common Language Runtime and its uses | Common Language Runtime In .Net Framework
Process Of Common Language Runtime
Compiling and executing code that runs on the dot net framework (managed code)
- First, you write the program code in the language of your choice.
- Then that code is compiled by the compiler of that language.
- After compiling a file is created which we call a portable executable file in which the written by you is converted into an intermediate language and which also contains some additional information. This information is called the metaday. Metadata contains complete details related to the program.
- The intermediate language and metadata are then linked to a library.
- After this compiler creates exe or dll file.
- When you execute this exe or dll file then the code from the base class library and all the relevant information is sent to the class loader. The job of a class loader is to load the code into memory.
- Just in time compiler translates the code from the intermediate language to managed native code. The Common Language Runtime provides a Just In Time compiler for each CPU.
- During code compilation, Just In Time compiles only those intermediate language code which are required during execution, instead of compiling the entire intermediate language. During this process, if any uncompiled method is awakened then just in time compiler compiles that intermediate language into native code for that method.
- Type safety checking of code is done during just-in-time compilation. Type safety ensures that the object will always be accessed in a compatible way. That is, if you pass the value to the method in 8 bytes instead of 4 bytes, then Just In Time will catch it.
- After converting IL to native code, the converted code is sent to dot net runtime manager. Dot Net Runtime Manager makes the code executable. During the execution of the code it is also ensured that the code has the right rights to access the resources.
Microsoft Intermediate Language – MSIL
The full form of MSIL is Microsoft Intermediate Language. It is also known as IL or Intermediate Language. It is also sometimes referred to as Common Intermediate Language.
So don’t get confused when these three names are used at different places. When you create a program (source code) in VB.NET or any language (C Sharp etc.) that targets the CLR and compile it, instead of compiling the source code into machine code, the compiler translates the code into Microsoft Intermediate Language. In doing so, language interoperability is ensured. Language interoperability refers to the freedom to work between more than one language.
Microsoft Intermediate Language can also be called the code between the source code and the local machine code. It is similar to the bytecode of Java. Terminology: Interoperability Synonyms It is a very difficult task to make exact Hindi synonyms of interoperability. Rather its exact Hindi is impossible. Interoperability is the ability of two different systems or components to exchange and use information.
When you write a program in any of the dot net framework supported languages in VB.NET, it is converted into an intermediate language by the source code compiler. The compiler creates metadata in the process of converting the code into an intermediate language. This metadata holds some important information related to the program such as classes and interfaces, versions of components used in the program, etc.
Both of these are linked in intermediate language and metadata assembly. All the applications developed in dot net framework are made up of assemblies. While executing the CLR application, it receives the information related to that application from the assembly itself.
The Dot Net Framework library or class library is a collection of frequently used classes that are linked with the Common Language Runtime. The class is object oriented and using it you can develop Console (DOS based), Windows GUI applications, ASP.NET based applications and Web Services, Windows Presentation Foundation Applications, Windows Services.
By doing this not only dot net framework classes are easy to use but also it takes less time to understand new features of dot net framework. Additionally, third party components can integrate seamlessly with classes from the dot.net framework.
For example, the Dot Net Framework implements a set of collection class interfaces that you can use to develop your own collection classes. Your compiled class will work seamlessly with classes from the dot net framework.
What is Namespace?
Namespaces are used to create logical groups of similar classes and interfaces that can be used by any language that targets the Dot Net Framework. Namespaces allow you to organize classes so that they can be used easily in other applications. Another use of namespaces is that they prevent name confusion between classes with the same name.
For example, an application may have classes with the same name in different namespaces. You can access the class of that namespace by importing a namespace in an application. Dot Net Framework uses a dot (.) between classes and namespaces to separate them. For example (System. Windows) represents the Windows class that belongs to the System namespace.
Question- : Mention the four roles of Common Language Runtime.
Answer – These are the four roles of Common Language Runtime.
1) Garbage Collection
2) Code Verification
3) Code Access Security 4) Intermediate Language to Native Language Translation