Sunday 18 September 2016

How .net program is executed by differently from other languages?




Why the assembly is used?


If we want to execute c++ or vb programs first we compile the program. Result is an assembly file. Extension of file depend upon the type of program. it may be .dll or exe. Actually why should we use assembly?. Because our operating system can not understand high level languages. we have to converted in to machine code  which is only 0 or 1.that is what assembly contains

What happens in case .of java?


In java files are not compiled into machine code. That is converted into class files. It will not be in  human readable form. it is because java is platform independent .The JVM(java virtual machine) responsible for execution is different for every platform. So JVM interpret class files of java and run it.

What is the Usage of CLR?


   In .net we can run c#, vb.net, c++,  j# ext. like JVM in java there is CLR (Common Language runtime)which manages the program running. Also it takes care for memory management. For example when we create object for a class. In language like c++ it allocates memory. But even after finishing the execution of program the memory is not freed. we have to manually write destructors for freeing memory. But in case of .NET there is a garbage collector which runs when we run the program it frees the memory by objects not in use. Even garbage collector can be manually called. But it is not a good programming practice.

Before entering in CLR the program(written in languages like c#,vb.net,c++ or,j#) are first compiled in to assembly but is not any machine code or class files. It is intermediate language that assembly contains. somebody calls itself as MSIL(Microsoft intermediate language. Others calls it as  CIL(common intermediate language. During the execution of program MSIL enters into CLR which contains JIT(Just IN time Compiler). It translates assembly code in to native machine code .and then executes the program.

What is the extension of Assembly file?


Assembly file extension may be .dll or .exe. For example when we build windows application .exe file get generated. But in case of class library or web application .dll file get generated. Main advantage of using CLR is it is portable.  Machine code generated by JIT compiler depends upon which underlying OS(operating system) it is going to run. And MSIL is also called Managed code. CLR managing code of the assembly code so it is called managed code.

What happens to code generated by CLR after stopping the execution of program?


And after stopping the execution of a program the code generated by CLR get deleted. While all other languages are managed code ,the code of c++ is available as both Managed and unmanaged code. the reason is c++ programs have to be backward compatibility for projects already created before inventing .NET.I think you would know about visual c++ language one of the component  of visual studio 6.0.







No comments:

Post a Comment