As we all know, computer machines only understands binary or native code. Accordingly, when we execute a Non-Dotnet application(e.g C++ or VB6), the C++ or VB6 compilers will execute the respective language source code in binary code, which is then understood by operating system and terminal hardware for processing.
Non-Dotnet Application Program Execution:
Since, binary code is generated specific to operating system, if you copy and try to execute the compiled binary code on another operating system(e.g Unix), it will fail due to portability issues between platforms (Windows and Unix).
Now, we will understand how a .NET program is executed. Eventually, .NET can be used to create different types of applications such as Web, Windows, Console and Mobile applications. Every type of .NET applications executed undergoes the below steps:
- The .NET Application source code is compiled into Intermediate Language (IL) which is also referred as Microsoft Intermediate Language(MSIL) and Common Intermediate Language(CIL). Both .NET and Non-.NET applications generate an assembly. Assemblies have an extension of .dll and .exe. For example, if you compile an windows or Console application it generates an .exe, where as we compile a web or class library project we see a .dll
- The difference between a .NET and Non-.NET assembly is that .NET assembly is in Intermediate Language format where as Non-.NET is in binary code format.
- Non-.NET applications run directly on top of Operating system, where as .NET application run on top of Common Language Runtime (CLR) Environment which contains Just-In-Time(JIT) compiler which in-turn converts the IL code to binary code.
.Net Application Program Execution:
As we discussed before, .NET assemblies are converted into IL code and not binary code, they can be executed/portable on any platform provided we have target platform as CLR environment. Intermediate Language is also called as Managed Code, because CLR manages the code that runs inside IL. For example in C++ program, the developer is responsible for de-allocating the memory assigned to the object. If a programmer forgets to de-allocate the memory object, we may run into memory leakage problems resulting into runtime out of memory exceptions. On the other side of .NET, de-allocating the memory object is taken through CLR by automatically running garbage collection process. Since, CLR is managing and executing the Intermediate Language, IL is also referred to as Managed code.
.NET platform supports various programming languages like C#, VB and C++. C# can only generate IL managed code, whereas C++ can generate both Managed(IL) and Un-Managed(binary) code. Binary code is persistent only when the program is in execution environment, after the program is closed it gets destroyed.
No comments:
Post a Comment