JVM, MSIL and .Net

Honors Computer Systems Organization (Prof. Grishman)

The Java Virtual Machine was initially designed as a machine-independent platform for running Java programs, and Sun's own focus has remained on the use of Java for network tasks.  Sun's emphasis in successive versions of Java has been to integrate a growing set of utilities and services -- particularly, Web services -- into the libraries, so that Web systems can be implemented more easily.

However, as this platform became widely distributed on many different machines, it became attractive to use JVM as a target for other programming languages.  A number of different compilers have been developed which generate JVM code (one catalog lists about 160 language systems, including those with Java-based interpreters and those which generate JVM code).  For languages which are a good match for the JVM, JVM provides many services that would have to be written from scratch for a conventional machine, such as memory management with garbage collection and a rich set of IO, graphics, and networking functions.  On the other hand, the strict typing and protection make it very hard to implement some of the 'dirtier' features of C and C++ involving pointers in JVM.

Microsoft has also been interested in the possibilities of a common network-wide platform for program distribution. They are, of course, concerned that their near-monopoly on operating systems not be eroded by the transition from individual desktop computing to networked computing.   Not wanting to follow the Sun/Java line, they developed their own architecture called the .NET Framework.   Like Java, the design is based on a virtual machine which can be implemented on many real machines.  Microsoft's machine executes MSIL, Microsoft Intermediate Language.  In many ways it is similar to JVM:  it is a stack-oriented machine with explicit typing of all operands, explicit object creation, type and instance methods, memory management (including garbage collection), and threading.  Looking at a small example of MSIL, you can see it's basic similarity.  In Microsoft's system (for Windows), the MSIL is translated into machine code by a "Just In Time" compiler (the MSIL is not interpreted).  However, there is also an effort to develop an open source implementation of .NET (the Mono project), which includes MSIL interpreters for many machines.

Microsoft emphasized from the start that this would be a common base which could be used with a number of programming languages.  Microsoft provides compilers for four languages:  C++, Visual Basic, J#, and C#.  J# is Microsoft's version of Java;  C# is also based on Java, but provides some additional capabilities.NET includes a Common Type System, shared by the 4 languages, a Common Language Specification, and a Common Language Runtime.  This makes is possible to assemble systems in which parts are written in different programming languages.  Other developers have produced compilers for additional languages, such as COBOL,  which target the Common Language Runtime (CLR).

C++ addresses the problem of moving to the .Net framework through "Managed Extensions" -- you can mix old ("unmanaged") code with new ("managed" code) which makes use of the CLR.  Similarly, in C# you can have "unsafe" code which does not use the CLR.