日期:2012-08-13  浏览次数:20493 次

.NET Framework For Java Programmers
Author: Ashish Banerjee

Objective

After reading this article Java programmers should be able to decipher and de-jargonize the .NET architecture and relate it with the proposed ECMA standard.
  

Target Audience

Java programmers and system architects.

Summary

This article outlines Microsoft's proposed standardization of .NET framework in ECMA forum as CLI (Common Language Infrastructure), but the Microsoft documentation refer this as CLR (Common Language Runtime). The CLR and JVM are compared with respect to market forces which shaped the CLR definition. Components of CLR are examined followed by details of Microsoft's implementation of the CLR as the .NET framework.
All along .NET framework is compared with Java architecture.
The material is derived from author's own experience with Java since early 1996, Microsoft's MSDN site and standard documents from sites like ECMA and W3C.org.

Overview

.NET framework is the Microsoft's answer to Java commune's objections to  \"Windonization\" of Java.
Microsoft introduces a new language C#, designed by the Visual J++ team. But in the process it has done away with DCOM and also have changed it's flagship language Visual Basic.
In a nutshell, .NET constitutes presently of three compiled languages C#, VB.NET and C++, a Java like runtime virtual machine environment, five execution containers hosting this runtime, namely: ASP.NET, Windows Shell, VBA scripting host for Office suite, Visual Forms container and IE (Internet Explorer). Much like Java it contains a rich set of API and lib.
Enhancements over Java framework include use of SOAP (Simple Object Access Protocol) for remoting. Version and security scoping using concept of Application Assembly (described later). A Common Type System is introduced for making mixed language programming easier. For example a VB component can inherit from a C# class.
In longer term Java and .NET will converge and therefore an overview of the new framework is presented here from Java programmer's perspective.

Comparing  CLR with JVM

The .NET framework's Common Language Runtime (CLR) is much similar to Java Virtual Machine (JVM), in terms of garbage collection, security, just in time compilation (JIT).
However, the fundamental difference arises from the variance in perception of the Sun's Java design team headed by James Gosling and that of Microsoft's C# designers spear headed by Anders Hejlsberg
Sun viewed the Internet as an heterogeneous network consisting of multiple operating systems. Thus Sun had to design the GUI as the least common factor, supportable by all such platform. This was also the major reason of Java's failure in client side applications. Java has been successful only on server side where there is no great need for GUI.
Having failed at client side desktop application arena, Sun is now targeting Java to server side applications market, which is dominated by Unix and Linux flavors having approximately 60% of the server market, the rest 40% rests with Windows NT.
But this view was not conducive to Microsoft, which holds about 90% of client side desktop market. Microsoft wanted to provide a window centric Internet development platform. Thus it added a few Window specific features in it's Java implementation, similar to what it had had done with it's C++ implementation. This along with Microsoft's refusal to support Java RMI, which competed with it floundering remoting technology called DCOM, resulted a law suite. Microsoft lost the law suite in late 2000, and had to pay USD 20 million  to Sun as settlement amount. This antagonist attitude made Microsoft break away from Java and float it's own language called C#.
The C# team was carved out of the Microsoft J++ team, and it's effort finally led to the creation of .NET framework