Microsoft .NET与J2EE的比较[E]

j2ee|比较

Microsoft .NET vs. J2EE:
How Do They Stack Up?

What exactly is the .NET platform [and] how does the .NET architecture measure up against J2EE?

Java runs on any platform with a Java VM. C# only runs in Windows for the foreseeable future.

.NET and J2EE offer pretty much the same laundry list of features, albeit in different ways.

By allowing cross-language component interactions, .NET is enfranchising Perl, Eiffel, Cobol, and other programmers.

.NET is a good thing for those of you committed to Microsoft architectures.

.NET will undoubtedly become the default development environment for Microsoft platforms.

However, several of the goals of the .NET platform are fairly lofty and not at all guaranteed to fly, at least not in the short term.

It would be easy to dismiss .NET as more Microsoft marketing-ware and continue on your merry way. But don't.

[Microsoft is] fighting Java and open source initiatives on their own terms, putting their own spin on "open" and attempting to directly address the needs of developers.

If you consider yourself an evangelist for Java or open source platforms, then the nature of the war is changing. Be prepared.

Microsoft has put a stake in the ground with SOAP, and they're pushing hard to put something understandable and useful in the hands of developers. J2EE proponents need to do the same with their platform.

Even if you don't write code dedicated to Microsoft platforms, you have probably heard by now about Microsoft .NET, Microsoft's latest volley in their campaign against all things non-Windows. If you've read the media spin from Microsoft, or browsed through the scant technical material available on the MSDN site, or even if you attended the Microsoft Professional Developers' Conference (where the .NET platform was officially "launched"), you're probably still left with at least two big questions:

What exactly is the .NET platform?
How does the .NET architecture measure up against J2EE?
And, if you think more long-term, you might have a third question rattling around your head:

What can we learn from the .NET architecture about pushing the envelope of enterprise software development?
The .NET framework is at a very early stage in its lifecycle, and deep details are still being eked out by the Microsoft .NET team. But we can, nevertheless, get fairly decent answers to these questions from the information that's already out there.

What is it?
Current ruminations about .NET in various forums are reminiscent of the fable of the three blind men attempting to identify an elephant: It's perceived as very different things, depending on your perspective. Some see .NET as Microsoft's next-generation Visual Studio development environment. Some see it as yet another new programming language (C#). Some see it as a new data-exchange and messaging framework, based on XML and SOAP. In reality, .NET wants to be all of these things, and a bit more.
First, let's get some concrete details. Here's one cut at an itemized list of the technical components making up the .NET platform:

C#, a "new" language for writing classes and components, that integrates elements of C, C++, and Java, and adds additional features, like metadata tags, related to component development.

A "common language runtime", which runs bytecodes in an Internal Language (IL) format. Code and objects written in one language can, ostensibly, be compiled into the IL runtime, once an IL compiler is developed for the language.

A set of base components, accessible from the common language runtime, that provide various functions (networking, containers, etc.).

ASP+, a new version of ASP that supports compilation of ASPs into the common language runtime (and therefore writing ASP scripts using any language with an IL binding).

Win Forms and Web Forms, new UI component frameworks accessible from Visual Studio.

ADO+, a new generation of ADO data access components that use XML and SOAP for data interchange.
How do .NET and J2EE compare?
As you can see, the .NET platform has an array of technologies under its umbrella. Microsoft is ostensibly presenting these as alternatives to other existing platforms, like J2EE and CORBA, in order to attract developers to the Windows platform. But how do the comparisons play out item-by-item? One way to lay out the alternatives between .NET and J2EE is shown in the following table:

Microsoft.NET J2EE Key differentiators
C# programming language Java programming language C# and Java both derive from C and C++. Most significant features (e.g., garbage collection, hierarchical namespaces) are present in both. C# borrows some of the component concepts from JavaBeans (properties/attributes, events, etc.), adds some of its own (like metadata tags), but incorporates these features into the syntax differently.
Java runs on any platform with a Java VM. C# only runs in Windows for the foreseeable future.

C# is implicitly tied into the IL common language runtime (see below), and is run as just-in-time (JIT) compiled bytecodes or compiled entirely into native code. Java code runs as Java Virtual Machine (VT) bytecodes that are either interpreted in the VM or JIT compiled, or can be compiled entirely into native code.

.NET common components (aka the ".NET Framework SDK") Java core API High-level .NET components will include support for distributed access using XML and SOAP (see ADO+ below).
Active Server Pages+ (ASP+) Java ServerPages (JSP) ASP+ will use Visual Basic, C#, and possibly other languages for code snippets. All get compiled into native code through the common language runtime (as opposed to being interpreted each time, like ASPs). JSPs use Java code (snippets, or JavaBean references), compiled into Java bytecodes (either on-demand or batch-compiled, depending on the JSP implementation).
IL Common Language Runtime Java Virtual Machine and CORBA IDL and ORB .NET common language runtime allows code in multiple languages to use a shared set of components, on Windows. Underlies nearly all of .NET framework (common components, ASP+, etc.).
Java's Virtual Machine spec allows Java bytecodes to run on any platform with a compliant JVM.

CORBA allows code in multiple languages to use a shared set of objects, on any platform with an ORB available. Not nearly as tightly integrated into J2EE framework.

Win Forms and Web Forms Java Swing Similar web components (e.g., based on JSP) not available in Java standard platform, some proprietary components available through Java IDEs, etc.
Win Forms and Web Forms RAD development supported through the MS Visual Studio IDE - no other IDE support announced at this writing. Swing support available in many Java IDEs and tools.

ADO+ and SOAP-based Web Services JDBC, EJB, JMS and Java XML Libraries (XML4J, JAXP) ADO+ is built on the premise of XML data interchange (between remote data objects and layers of multi-tier apps) on top of HTTP (AKA, SOAP). .NET's web services in general assume SOAP messaging models. EJB, JDBC, etc. leave the data interchange protocol at the developer's discretion, and operate on top of either HTTP, RMI/JRMP or IIOP.

The comparisons in this table only scratch the surface. Here's an executive summary of .NET vs. J2EE:

Features: .NET and J2EE offer pretty much the same laundry of list of features, albeit in different ways.

Portability: The .NET core works on Windows only but theoretically supports development in many languages (once sub-/supersets of these languages have been defined and IL compilers have been created for them). Also, Net's SOAP capabilities will allow components on other platforms to exchange data messages with .NET components. While a few of the elements in .NET, such as SOAP and its discovery and lookup protocols, are provided as public specifications, the core components of the framework (IL runtime environment, ASP+ internals, Win Forms and Web Forms component "contracts", etc.) are kept by Microsoft, and Microsoft will be the only provider of complete .NET development and runtime environments. There has already been some pressure by the development community for Microsoft to open up these specifications, but this would be counter to Microsoft's standard practices.

J2EE, on the other hand, works on any platform with a compliant Java VM and a compliant set of required platform services (EJB container, JMS service, etc., etc.). All of the specifications that define the J2EE platform are published and reviewed publicly, and numerous vendors offer compliant products and development environments. But J2EE is a single-language platform. Calls from/to objects in other languages are possible through CORBA, but CORBA support is not a ubiquitous part of the platform.

The Bigger Picture
These last points highlight some of the key differentiators between .NET and J2EE, and point towards Microsoft's real play here. Microsoft is doing two very notable things with .NET: It is opening up a channel to developers in other programming languages, and it is opening up a channel to non-.NET components by integrating XML and SOAP into their messaging scheme.
By allowing cross-language component interactions, .NET is enfranchising Perl, Eiffel, Cobol, and other programmers by allowing them to play in the Microsoft sandbox. Devotees of these languages are particularly amenable to gestures like this, since for the most part they have felt somewhat disenfranchised and marginalized in the Microsoft/Sun/Open Source wars. And by using XML and SOAP in their component messaging layer, Microsoft is bolstering their diplomatic face and adding an element of openness to their platform, providing ammunition against claims of proprietary behavior.

What's the correct response?
For Microsoft developers:
.NET is a good thing for those of you committed to Microsoft architectures. ASP+ is better than ASP, ADO+ is better, but different, than ADO and DCOM, C# is better than C and C++. The initial version of .NET won't be real until sometime in 2001, so you have some time to prepare, but this will undoubtedly become the default development environment for Microsoft platforms. And if you're developing within the Microsoft development framework now, you will undoubtedly benefit from adopting elements of the .NET framework into your architectures.

However, several of the goals of the .NET platform are fairly lofty and not at all guaranteed to fly, at least not in the short term. The IL common language runtime, for example, has some fairly significant hurdles to overcome before it has any real payoff for developers. Each language that wants to integrate with the component runtime has to define a subset/superset of the language that maps cleanly into and out of the IL runtime, and has to define constructs that provide the component metadata that IL requires. Then compilers (x-to-IL and IL-to-x) will have to be developed to both compile language structures (objects, components, etc.) into IL component bytecodes, and also generate language-specific interfaces to existing IL components.

There is some historical precedence here. Numerous bridges from non-Java languages to the Java VM have been developed, such as JPython, PERCobol, the Tcl/Java project, and interestingly enough, Bertrand Meyer and some other Eiffel folks put together an Eiffel-to-JavaVM system a few years back. With the possible exception of JPython, these tools have not been widely adopted, even within their respective language communities, even though they seem to offer a way to write code for the Java environment (albeit not the entire J2EE framework) using your favorite language. Why this lack of enthusiasm? I believe it's because people are hesitant to take on the headaches of adding yet another translation step from their development language to the target framework. If the Java environment is the goal, people will generally choose to learn Java. I predict that the same will be true of .NET: People will generally choose to learn C# and write .NET components in that language.

Another caution: Beware of performance issues with .NET's SOAP-based distributed communications. SOAP essentially means XML over HTTP. HTTP is not a high-performance data protocol, and XML implies an XML parsing layer, which implies more compute overhead. The combination of both could significantly reduce transaction rates relative to alternative messaging/communications channels. XML is a very rich, robust metalanguage for messaging, and HTTP is very portable and avoids many firewall issues. But if transaction rates are a priority for you, keep your options open.

For the Java and Open Source communities:

It would be easy to dismiss .NET as more Microsoft marketing-ware and continue on your merry way. But don't. .NET is a sign of a subtle but significant shift in Microsoft's strategy to evangelize their platforms. They have been fighting alternative frameworks and platforms at the management level pretty well, touting the usual questionable "statistics" about cost of ownership and seamless integration. Now they are fighting Java and open source initiatives on their own terms, putting their own spin on "open" and attempting to directly address the needs of developers, two things that they have been faulted for not doing very well in the past. If you consider yourself an evangelist for Java or open source platforms, then the nature of the war is changing. Be prepared.

Also, Microsoft's IL runtime has at least one notable, if improbable, goal: eliminate the programming language as a barrier to entry to the framework. Java eliminates the platform barrier (within limits, of course: You can't make up for missing hardware resources with software, for example), but in order to work in J2EE, you have to work in Java. .NET wants to let you use the language of your choice to build .NET applications. This is admirable, though there are big questions as to whether and when the IL approach in .NET will actually become broadly useful (see above). Regardless, this points to a weakness in the single-language J2EE approach. The importance of this weakness is questionable, but it exists nonetheless, and deserves some consideration by the Java community. If this is really desired by developers, then maybe the efforts in Java bytecode generators for non- Java languages should be organized and consolidated.

Focusing on J2EE, there are a few issues that should be addressed immediately in order to bolster the advantages of that platform compared to what .NET is shooting for. First, XML support needs to be integrated seamlessly into the framework. I'm not talking about bolting an XML SAX/DOM parser to the set of standard services, or extending the use of XML in configuration files. XML messaging and manipulation need to be there, ready to use. Admittedly, you can use XML payloads on top of JMS messaging, but the platform doesn't facilitate this at all. The XML space is a cluttered mess of standards, de facto standards, APIs and DTDs, which is to be expected when you're dealing with a meta-language.

But Microsoft has put a stake in the ground with SOAP, and they're pushing hard to put something understandable and useful in the hands of developers. J2EE proponents need to do the same with their platform. One possibility that comes to mind is to add an XML messaging "provider" layer on top of JMS, along the lines of the pattern followed by Java Naming and Directory Interface, or JNDI, with LDAP, NIS, COS Naming, etc. This in combination with a standard SOAP/BizTalk provider, an ebXML provider, etc. would be an impressive statement.

Clarifications and Corrections
Since the publication of this article in August 2000, 40 readers have responded with their own thoughts about .Net vs. J2EE. (See the Reader Responses.) Jim Farley, the author of this article, has sifted through those comments, as well as email he's received, and added the following clarifications and corrections.
Clarifications
The description of C#'s compilation features vs. those of Java seems to have confused some readers. To put it another way: C# code always runs natively. Java code typically runs as interpreted bytecodes, and can run natively. C# is either compiled entirely to native code, or it is compiled into the common language runtime bytecodes and then just-in-time compiled to native code during execution. Java code, on the other hand, typically runs as runtime-interpreted bytecodes (from which its cross-platform abilities spring), and can also run in a just-in-time compiled context. Some Java native-code compilers also exist (Jove, BulletTrain, JET, etc.).
As a side note, Microsoft claims that the default interpretive mode of Java is a liability, in that bytecodes designed for a virtual machine do not lend themselves as well to native optimization. I haven't seen any hard data to prove or disprove that claim, either generally (bytecodes vs. native-compiled languages) or specifically (Java vs. C#).

Several readers, in response to the call to include XML support in J2EE, mentioned the fact that J2EE 1.3 (currently in public draft) requires that any J2EE-compliant product must include Java XML SAX and DOM parsers. But this is just "bolting an XML SAX/DOM parser" to J2EE, as I mentioned. I was calling for it to be taken a step farther, to incorporate XML support directly in the J2EE support APIs. Ideally, J2EE-based components and services would have XML support (for messaging, interface description exports, etc.) automatically built-in, to some extent.

Corrections
I state in the article that C# "borrows some of the component concepts from JavaBeans." This statement can't be proven, and, as several readers pointed out, it's more likely that Microsoft based the component functionality of C# more on their own COM and VB models, with influences from other pre-existing component models.

时间: 2024-07-30 03:53:27

Microsoft .NET与J2EE的比较[E]的相关文章

Microsoft .NET vs. J2EE: How Do They Stack Up?

What exactly is the .NET platform [and] How Does the .NET architecture measure Up against J2EE? Java runs on any platform with a Java VM. C# only runs in WinDows for the foresEEable future. .NET and J2EE offer pretty much the same laundry list of fea

继续推荐俺的《新概念ASP.NET教程》

asp.net|概念|教程 图书版权信息图书编号:D08107884 图书名称:新概念ASP.NET教程 出版社:北京科海集团出版社 译作者:王洪超 出版日期:2001年4月 国标编号:ISBN 7-89999-332-6 条形码:9787899993323 印张:20字数:436千字 页数:305开本:787*1092 1/16 印数:0001-5000 备注:1CD图书定价:¥33会员价:¥28.05立即节省:¥4.95[浏览相关图书]     本书对于微软新世纪的重头产品ASP.NET做了

J2EE vs. Microsoft.NET 之 Web Services

j2ee|services|web J2EE vs. Microsoft.NET 之 Web Services             --建置XML架构的Web Services之比较作者:佚名    本文选自:CNJSP  2002年04月30日 I. 序 在本文中,我们将深入的比较两种可用来建置商业XML Web Services的平台,分别是Sun Microsystems 所提供的Java 2 Enterprise Edition (J2EE)以及Microsoft所提供的 .NET平

用AJAX+J2EE实现网上会议系统

今年大家都在炒作Web2.0,其中的一门技术Ajax也是跟着火了起来,因此前面我写了一篇名为<忽悠一下AJAX>的文章,简单地分析了一下Ajax的技术的实质.虽然笔者不太喜欢跟风,但Ajax有一些地方还是比较有用的.前段时间做了EasyJF开源团队的网上会议系统,就用到了Ajax技术,下面把设计思路发出来跟大家分享一下. 一.系统实现的功能 本会议室系统主要用于EasyJF开源团队的成员网上会议使用,会议系统模拟传统的会议形式,可以同时开设多个不同主题的会议室,每个会议室需要提供访问权限控制功

利用AJAX+J2EE开发组织机构管理系统(3)

ajax|j2ee|机构管理 function addPerson(){ var seqNo = nextSeq; nextSeq++; var peorsonNode = personDom.createNode("1", "peorsone",""); peorsonNode.setAttribute("isNew", "Y"); peorsonNode.setAttribute("isDel

利用AJAX+J2EE开发组织机构管理系统(2)

ajax|j2ee|机构管理 <body > init方法实现如下: function init(){ //定义personDom为一个XMLDOM'对象 personDom= new ActiveXObject('Microsoft.XMLDOM'); personDom.async = false; //定义stylesheet为一个XMLDOM'对象,且stylesheet为personDom确定显示风格 stylesheet = new ActiveXObject('Microsoft

用AJAX+J2EE实现网上会议室系统

ajax|j2ee|网上会议 <br /> <DIV twffan="done"> 今年大家都在炒作Web2.0,其中的一门技术Ajax也是跟着火了起来,因此前面我写了一篇名为<忽悠一下AJAX>的文章,简单地分析了一下Ajax的技术的实质.虽然笔者不太喜欢跟风,但Ajax有一些地方还是比较有用的.<table border="0" cellspacing="0" cellpadding="0&

详解J2EE的13种核心技术

j2ee|详解 Java最初是在浏览器和客户端机器中粉墨登场的.当时,很多人质疑它是否适合做服务器端的开发.现在,随着对Java2平台企业版(J2EE)第三方支持的增多,Java被广泛接纳为开发企业级服务器端解决方案的首选平台之一.J2EE平台由一整套服务(Services).应用程序接口(APIs)和协议构成,它对开发基于Web的多层应用提供了功能支持.本文将解释支撑J2EE的13种核心技术:JDBC, JNDI, EJBs, RMI, JSP, Java servlets, XML, JMS

.NET vs J2EE——面对SOA的荒谬与误解

·.Net与J2EE在金融行业愈来愈呈势均力敌之势,二者均宣称提供了不同于对方的.听起来很迷人的个性化应用服务. ·理性的IT执行官们已经深刻的认识到这样的一个事实:无论是.Net还是J2EE,将来必将在SOA理念的应用中占有各自的一席之地. ·Microsoft的.Net技术在今天的金融市场面前,显得商机无限. ·从前,荒诞与误解依然在.Net与J2EE平台之间萦绕着:似乎没有一个IT决策者能够看透了这层迷雾,继而在两个平台之间做出理性的决择. ·今天,技术执行官们已经能够很好的把握需求动机,