Picking a Winner: .NET vs. J2EEMARCH 2001
Although Both Frameworks Stand on a Foundation of Programming Languages, Object Models and Virtual Machines, They Are Strikingly Different When You Consider The Design Goals of Their runtime environment.
By Jim Farley
The Java 2 Enterprise Edition (J2EE) framework has captured significant mindshare among online application developers and their organizations, as a powerful, portable and widely-supported application development environment. Microsoft's announcement of .NET (dot-NET) has captured the attention of just as many, since it represents the future direction of all things Microsoft, from desktop applications like Microsoft Office to development tools like Visual Studio to back-end servers like SQL Server, and everything in between.
Opinions on the ultimate outcome of this framework competition range far and wide-zealots on either side of the "demilitarized zone" claim emphatically that either Sun and J2EE or Microsoft are doomed to fail. Some of the more balanced analysts predict a near-term stalemate , with J2EE and dot-NET eventually claiming a roughly equal share of the application development market. This prediction seems the most sensible, given the two forces facing off-J2EE with a significant amount of development inertia and a broad array of tool and application vendors BEHIND IT, AND DOT-NET with the Marketing Influnce of Microsoft Fueling ITS SPREAD.
Regardless of the long-term result, it seems unavoidable that technology managers, strategists and software developers will have to contend with both of these frameworks for some time to come, and I've tried to provide some guidance to the development community around this " . framework divide "Whether you're part of an organization committed to either J2EE or Microsoft platforms, trying to assess the costs and benefits of sticking with your current framework, jumping to the other or attempting to support both; or if you're an organization about to venture into a development effort and attempting to pick the most suitable path, I've attempted to lay out the two frameworks as clearly and unambiguously as possible. (half-) Sisters Under the SkinIt's important to acknowledge that despite what the best Marketing Minds At Sun and Microsoft Might Lead You To Believe, Dot-Net and J2ee Are Surievely Similar From A Pragmatic Standpoint. Both Offer A Server- and Client-Side Component Model for As sembling enterprise applications, APIs that allow you to create both fat and thin user interfaces for these applications, and specifications and corresponding APIs that allow you to access critical services such as transactional data sources, directory services and remote objects.
At a lower level, the two frameworks are both based on a virtual machine architecture aimed at portability (though the type of portability each strives for is a critical difference between the two). Also, J2EE and dot-NET are comparable in some areas in Terms of Feature Support and architecture.
Do not Know Beans? When J2EE was introduced by Sun, it subsumed, to a large degree, the JavaBean and Enterprise JavaBean component models. JavaBeans are the meat-and-potatoes Java components, with well-defined properties, event-handling provisions ., persistence through Java serialization and introspection, in addition to all of the basic services provided by the Java runtime environment, like memory management, "sandbox" security and the core Java APIs Enterprise JavaBeans are the distributed equivalent: remotely-accessible components that operate WITHIN An Environment That Provides Application Security, Distributed Transaction Support, Richer Persistence Management Facilities, Life Cycle Management and Resource Pooling.
The dot-NET framework, meanwhile, subsumes Microsoft's workhorse COM and COM component models. These component models are replaced, in a sense, by the new component architecture of the dot-NET framework. The Common Language Runtime (CLR) now provides "sandbox "security and basic services like garbage collection, similar to the Java Virtual Machine, which were not available previously in the COM and COM environments. It also extends the component model itself with features such as multiple interface inheritance, extensible meta-data and a new delegate model. So the CLR defines a new, richer component model, which COM and COM components can be mapped into, and which is accessible by COM and COM components, but it is separate and distinct from COM. This has fueled doubts as to whether COM and COM will continue as "first-class" supported programming models in Microsoft's product line (See Don Box's article, "House of COM," in the December 2000 issue of MSDN magazine on how the new CLR environment differs from the COM environment) .Microsoft's support for components has a long history, driven in part by the fact that it provides the principal visual IDE for Microsoft developers (Visual Studio and its predecessors). Microsoft has had the luxury of taking its component model through several iterations of improvements, despite the subsequent churn inflicted on its developers. Java's component model inherited the institutional learning that came before it, but improvements to the Java component model are handicapped to some degree by its dependence on the Java language and the open Nature of Java's Evolution.
The Skinny on Fat ClientsFor "fat" GUI clients, J2EE offers the Java Swing API, with a palette of standard GUI JavaBean components that can be assembled programmatically, or pulled into visual GUI design tools like WebGain (formerly Symantec) Visual Cafe, Borland JBuilder , IBM VisualAge for Java and so on. for thin-client development, the servlet and JavaServer Pages (JSP) standards provide ways to build HMTL, WML, XML and other thin interfaces on top of a Java middle tier. Java servlets and JSPs are supported by a number of application server vendors, both commercial (such as BEA WebLogic, iPlanet, IBM WebSphere and SilverStream), and open source (for instance, Apache's Jakarta project, Enhydra and Resin) .In the past, Microsoft has offered "fat "client support through its Microsoft Foundation Classes (MFC) API, but dot-NET offers a new set of components:. Windows Forms Windows Forms fill the same functional role as MFC, but they are plugged into the new dot-NET runtime framework and c Omilarly, on the Thin-Client Front, ASP.NET IS The Dot-Net Successor To Active Server Pages (ASP): Functionally, IT Fills The Same Role As A Thin-Client (HMTL, WML OR XML) Paradigm for applications, but ASP.NET pages participate in the new CLR. in this case, that means that code snippets and component references can be added to pages using any CLR-compliant language, and ASP.NET pages are compiled into the IL-based CLR Runtime, Rather Than Interpreted, AS ASP Pages Are.
Data Sources and Directory ServicesJ2EE and dot-Net both support, in different ways, a few strategic APIs and services such as access to data sources and directory services, and general-purpose XML support for applications. Access to data sources within the Java environment is handled through JDBC, an RDBMS-independent Java specification for interfacing with relational databases. Specific vendor RDBMSs are supported through JDBC drivers, which are available for all of the popular commercial and open-source database options.JDBC is a fairly low-level API, in that it models database access in terms of Connections, Statements and ResultSets. JDBC 2.0 and its standard extensions add useful services such as connection pooling and support for Open XA distributed transactions-J2EE 1.2.1 (the current industry-supported version of the standard ) Doesn't Mandate The Extensions, But J2ee 1.3 (Currently In Developments) Does. Higher-Order Data Access Services Are Provided Withnin J2EE by Entity EJB s and the persistence management services of EJB containers. Commercial third-party object-relational tools, such as Sun's Java Blend or WebGain's TopLink, are also available, but are not strictly part of the J2EE framework.
Directory services are accessed in Java using Java Naming and Directory Interface (JNDI), and a different object model involving Names, Contexts and Attributes, which represent name-to-object mappings within a naming or directory service, and meta-data attributes associated with these objects within a directory. Access to various types of directory services, such as LDAP, Novell NDS, NIS, and more recently with DNS and Directory Services Markup Language (DSML) XML sources, are accomplished through JNDI providers, which are analogous to JDBC drivers.Microsoft's data-oriented services and APIs have had a bumpy past. Early efforts stemming from OLE and ODBC led to Data Access Objects (DAO), which led to the ActiveX Data Objects (ADO) API. ADO sits as a peer to both JDBC and JNDI-data access is modeled as Connections, Commands and Recordsets, and ADO provides unified access to both relational data sources and directory services. ADO has offered some features, such as record navigation and "Offline" rowset access, that were not available in JDBC until the 2.0 version of that specification. On the negative side, ADO rides on top of the COM-based OLE DB and ODBC interfaces, which severely limits its interoperability and scalability.
. In recognition of this, dot-NET replaces ADO with ADO.NET (Microsoft's earlier term for the dot-NET data access components was ADO ; It's unclear whether this change in nomenclature will stick or not, but in this article I'll use ADO.NET, instead of ADO , for simplicity). ADO.NET is a new data access API that replaces the COM-based marshalling of data with XML data transmission from data source to the ADO.NET data component. The API model is essentially the same-Recordsets are replaced with DataSets, Commands are replaced with DataSetCommands and so on. in the dot-NET framework, there is also the new System.DirectoryServices package, which provides interfaces specifically designed for accessing directories. The big difference in ADO. NET (from both its predecessor, ADO, and its competing APIs, JDBC and JNDI) is that the data transmission format from source to DataSet is XML, which allows ADO.NET to treat anything that emits XML in the ADO.NET schema as a Data Source. Contrast this with JDBC and JNDI, where the API allows the driver or provider to use whatever exchange protocol is appropriate (for example, an Oracle driver can use a JNI interface to the OCI libraries, or it can implement the SQL * net or NET8 protocols directly in Java ). It would be possible to implement a JDBC driver, for example, that communicates with a data source using XML, which would open up the same types of portability potential that ADO.NET promises. But the JDBC API does not expose this potential .
XML is a more accessible and portable data exchange protocol, and support for it within ADO.NET is good for developers and vendors alike. It opens up interesting possibilities in terms of exporting virtual "data sources," or components themselves being able to serve as a data source for each other. However, in practice, high-volume data exchanges would probably be better served by a more compact, efficient protocol dictated by the data source engine. XML is well-structured and humanly readable, but it's rather fat as data protocols go.General-Purpose XML SupportBoth Java and dot-NET provide the now-expected basic XML support, which includes APIs for Document Object Model (DOM) generation and parsing. The Java API for XML Processing (JAXP) is a Java extension API that supports DOM and SAX (Simple API for XML) models for XML sources, and provides a plug-in architecture for different parsing engines. Note that I did not mention J2EE here. J2EE 1.2.1 does not dictate that an XML API Be Prese nt in the environment-a requirement was not added until J2EE 1.3. Of course, this is largely academic, since virtually any Java application server has already, or is planned to have, a Java XML API and parser bundled. But the lack that Of a requirement for an XML API in The framework is a sign of the level of xml adoption present in j2ee.
This is not to say that Sun and the Java community have been slouches in the XML arena Quite the contrary XML support in the Java environment is plentiful and timely:.. New XML-related standards are almost ubiquitously implemented in Java, and typically before other languages. More recently, Sun has announced plans to define a standard Java API for XML Messaging (JAXM), which uses ebXML messaging to provide XML request and response services for the Java environment, and the Java API for XML Data Binding (JAXB) , which uses both XML Schema and XML Binding to define a standard Java API for the marshalling and unmarshalling of Java objects into and out of XML document models. At the time of this writing, these APIs are not formal elements of the J2EE framework and plans to incorporate them into its application, UI and data access services have not been announced.Microsoft has also embraced XML vigorously. At the ground level, the company provide its MSXML API for DOM and SAX parsing and XML g eneration. More importantly, XML is an underlying feature of dot-NET at many layers. We've already discussed how ADO.NET uses XML for its underlying data exchange protocol. In general, dot-NET components use XML by default for data representation of various kinds. An especially interesting aspect of the dot-NET architecture is the ability for dot-NET Web services to easily export an XML interface, in the form of SOAP, across the network. (See my article on the O'Reilly Web Site About The PROS AND CONS OF SOAP AS A DATA Exchange And RPC Mechanism.)
This provides for some interesting possibilities:. Clients of these SOAP-accessible Web services can take many forms, from client browsers to mobile devices to other Web services (implemented in dot-NET or in other frameworks) Again, the practicalities of having an XML parser in the mix, and the subsequent reduction in transaction rates, may keep you from using SOAP interfaces to dot-NET components in high-volume, high-scalability situations. But it's still nice to know that level of flexibility is there if you need it.Where the Code Hits the RoadFormal deployment schemes are an attempt to reduce the confusion of loosely-defined dependencies between libraries, classes and media assets sitting on local and remote file systems, and "component versioning hell."
In J2EE, applications are composed of modules, which are collections of interrelated components, which come in three major flavors:. Web components, EJB components and Java "clients" (which includes both application clients and applet clients) Each type of component is managed at runtime by a corresponding container type that provides it with services and APIs (for example, Web components have the JSP and Servlet APIs available through their container, while EJB components have access to the full EJB API and its security, life cycle and transactional services ).
The dot-NET environment proposes an analogous application assembly and deployment scheme. Dot-NET applications are built up from assemblies, which contain EXE and DLL files that contain compiled dot-NET components. Assemblies can also contain other required resources, like media assets, support code or classes, and so on. Assemblies can be packaged in the form of Windows Installer files (.msi), Windows CAB files (.cab), or they can be dynamically downloaded by a Web application (similar to the way Java applet context and browser plugins are currently downloaded). Dot-NET assemblies can be deployed as standalones, or they can be grouped into an application.Dot-NET defines an XML-based configuration scheme, where interassembly dependencies, security settings and resources are defined. Creation of DLLS, EXES, RESOURCE Files, Configuration Files and So ON CAN Be Accomplished Using Command-Line Tools Provided in The Dot-Net Framework SDK, or Graph Framework SDK, or Graph Framework SDK, or Graph Framework SDK, or Graph Framework Of Microsoft Visual Studio (Both of Which Are Available In Beta Form at the time of this write).
J2EE also makes use of XML deployment descriptors for modules and applications, in order to provide configuration information to the runtime J2EE environment. This configuration information includes a manifest of the contents of the module, component dependencies, details about required external resources, and security- related roles and access rights. Although the core Java environment supports command-line editing, a number of J2EE tool and application server vendors provide deployment tools that make point-and-click work out of the generation of XML deployment descriptors and the assembly of JavaBeans , servlets, JSPs and EJBs into JAR files, and the actual deployment of these modules and applications into running application servers, local or remote.This leads to another distinction between dot-NET and J2EE application deployment. Deploying a given J2EE component within a particular J2EE Server offen involves, in addition to modifying the deployment descriptors, The generation of ven dor-specific support classes for your components. This complicates matters with regards to tying application servers to integrated development environments. Dot-NET, as a single-vendor platform and framework, does not have to concern itself (or you) with this issue Since Microsoft Provides Both the development and deployment tools.
Dot-NET also does not make the same clear distinctions between different types of assemblies as J2EE does. There are clear application types (Web-based ASP.NET applications where ASP pages interact with back-end CLR components, or Windows Forms applications where the GUI is desktop Windows components interacting with CLR components), but the components themselves are not categorized by service-levels-it's assumed that all components can have access to all of the services and APIs of the dot-NET environment. Since Microsoft is the sole provider of dot-NET implementations, it does not have to include such multivendor considerations in the architecture.Critical DifferencesI've outlined some subtle differences between today's dot-NET framework and J2EE framework, and so far the two frameworks have been fairly Comparable ON A Pragmatic, Functional Level. However, There Are Critical Differences Between The Two Frameworks At A Number of Levels.
Dot-NET and J2EE both stand on a foundation of programming languages, object models and virtual machines. The most striking difference between the two frameworks is the design goals of their runtime environment and how these support very different programming and deployment schemes. The cliché developing in the community around this point is that "Java is language-specific and platform-independent, and dot-NET is language-independent and platform-specific." This cliché is in many ways an oversimplification since numerous J2EE implementations are not entirely cross -platform. Microsoft has made some preliminary attempts to make dot-NET cross-platform, such as submitting the CLR specification and the C # language to the European Computer Manufacturers Association for public standardization, as well as announcing versions of the CLR for a variety of Non-Pc Devices, Including the Linux Platform (if The IS A Market for IT). The Cliché Remains Fairly Accurate, Though, Because The J2ee Specifi cation is fundamentally cross-platform and the full dot-NET story incorporates Windows as a central piece.Figure 1. Competing Development ModelsJava's unified programming environment is platform-independent; XML-enabled dot-NET is language-independent.
J2EE is a framework that evolved out of the core Java environment, which is founded on the Java language, the Java Virtual Machine (JVM) and the Java core APIs. The Java programming model calls for class descriptions written in Java to be compiled into platform -independent bytecodes as defined by the Java Virtual Machine specification (Figure 1). These bytecodes are then interpreted and executed by an implementation of the JVM targeted for the particular platform at hand-Solaris, Windows, Linux, AIX and so on. The JVM defines and provides a standard runtime environment that provides memory management and security. Alternatively, Java code (or the resulting Java bytecodes) can be compiled to a native executable for a specific platform, or runtime compiled to native code by a just-in-time (JIT) Compiler. So, Development in J2EE IS Meant To Be Done in Java, Resulting In Class Bytecodes That Can Be Run On Any Platform With a JVM OR A Java-to-Native Compiler. Access to Objects and Component s written in other languages is possible, using the Java Native Interface (JNI) and CORBA, but these are largely ancillary to the core development and runtime model. In both cases, these are also rather complicated APIs to master, which in part hinders their Broad adoption.
Microsoft's dot-NET framework is based on its Common Language Runtime (CLR), which is composed of a specification for language-independent intermediate language (IL) code and a runtime that provides memory management, security and so on. This may seem analogous to the Java runtime architecture, but the difference is that code targeted for the dot-NET framework can be written in any language that supports the CLR's core component model. A compiler must be developed which compiles the code into IL-once there, the objects and components can run side-by-side and interact with components written in other languages and compiled into the CLR. Blocks of IL code are JIT-compiled into native Windows code, or your whole application and assembly can be compiled once into a native Windows DLL OR EXE AS SHOWN FIGURE 1.The Interesting Thing About this Difference In The Two Frameworks, And The Reason It's A Critical Differentiator, Is That Relative Low-Level Design Feature Strikes Right At e . Ach framework's strategic direction Java is designed to be a unified programming model that is platform- independent Sun would say (and has, in different words):. Once you have everything in the Java environment and the Java Virtual Machine, you gain tremendous flexibility In Choosing Tools And Off-The-shelf Components At Development Time, Platforms At Deployment Time and Interservice Connections and Live Code Sharing At Runtime.
Dot-NET, on the other hand, is a unified platform (Windows) that is language independent and deeply XML-enabled Microsoft might tell you:. Once you have everything in the Windows platform and the Common Language Runtime, you gain tremendous flexibility in the ability to choose the development language that's right for you at development time, and in interconnecting components and Web services at runtime, either at the component and object level using the CLR, or in a looser sense using SOAP and XML. and deployment time decisions are simplified because everything is integrated into the Windows environment.We'll return to the XML issue in a moment, but the language and platform distinction is critical. and there are chinks in the armor on either side of this architectural battle.
Java's true potential is realized by a development team and its surrounding organization only when a critical mass of development (or all of it) is done in Java. If, for some reason (legacy system, third-party requirements, component availability), a .
This language-centric approach is also limiting strategically. It's easy to imagine some powerful improvements to the Java core environment that would be best accomplished by making changes to the syntax of the Java language, and these changes are very difficult to make because there is a .
A good example is the explicit declaration of properties on JavaBeans. Given Java's preexisting syntax, the JavaBeans specification was defined so that component properties are implicitly defined by the presence of methods of a particular signature (setXXX and getXXX) on the bean's Java class. A better solution would be to have a way to explicitly declare properties, keeping the method namespace independent. Doing this, however, would require altering the syntax of the Java language to include a scheme for declaring properties explicitly, and changing the Java language itself would cause changes to ripple upwards through the APIs and specifications, and downwards into the JVM in some cases. Given the success of Java and the number of vendors coding to its specifications, this would be a herculean task in concensus-building and making provisions for migration and BACKWARDS-Compatibility. Ironically, It's Analog to the Woes That Microsoft Faced When It Attempted to Eliminate The Dos K ernel from its OS.Microsoft dot-NET, on the other hand, realizes its true potential only if it's necessary and prudent to create and manage components developed in multiple languages, and do it all on Windows. On the face of it, being able to use the language of your choice (from the set that supports MSIL compilation, that is) seems like a valuable possibility-if I do not know C # or C or Java, I can stay productive and write code in what I know, instead Of Starting a New Learning Curve. This is Appealing for Both Developers and Managers Alike, But The Clr Achieves Somewhat Less Than in Reality.
You can not write standard, ANSI-compliant C or standard COBOL or Eiffel and make it work in the CLR sandbox. To make your code accessible to other CLR components, you have to write your code in Managed Extensions to C , Eiffel # or COBOL #, which are syntactic variants of the original languages that they share names with. These variants include syntax extensions that are required in order to provide all of the component meta-data that the CLR requires, which can not be supported by the standard language This means two things:. there is still a learning curve to be climbed (although probably not a large one) in order to program to dot-NET's CLR, and the code that you write for dot-NET will not be understood by The Standard Compilers Or Interpreters for these Languages.as An Example, The Following IS A Class Written In Managed Extensions for C :
#using
Using Namespace System;
Namespace sdexample {
__GC public class simplecomponent {
Private:
String * mname;
PUBLIC:
SimpleComponent () {
MNAME = New String ("anonymous");
}
__property int GET_NAME ()
{Return Mname;
}
}
The red areas show the syntax elements that are not standard C . The "#using" preprocessor directive declares a Windows DLL that this component requires, the "__gc" tag marks this class as a CLR component eligible for memory management services, and the "__property" tag declares a property of the component. A developer still needs to learn the new component model of the CLR, and learn how the model impacts her "home" language, before she can write code for dot-NET. and ANSI- compliant third-party C compilers and tools will not understand this C variant-only dot-NET-enabled compilers can be used. The extensions to C that I've shown here are fairly minor, since C is a contemporary object-oriented programming . language and has a large overlap with the object model of the CLR Similar extensions were required to Eiffel to create "Eiffel #" (see the article "Eiffel on the Web: Integrating Eiffel Systems into the Microsoft .NET Framework" in the MSDN Library Other Languages, Such as the Non-Object-Oriented Cobol, Will Require More Significant Extensions in Order for Their Compiled Code To BE Accessible As First-Class Msil Components.
XML ServicesJ2EE has a lot of catching up to do on the XML front. Dot-NET uses XML and provides XML services from top to bottom. ADO.NET uses XML for data transmission, MSXML provides general-purpose XML parsing and generation capabilities for applications , and Web services can be exported as SOAP interfaces. in addition, Microsoft released a beta of its XML for analysis specification in October 2000, which defines a SOAP-based protocol for remote method calls and data exchanges over HTTP. All in all, dot -NET is making it very easy for developers to take advantage of XML in innovative ways.To its credit, Sun has been very active in the XML space, with the JAXP specification released in March 2000, then required in the J2EE 1.3 specification proposed final draft, which was released in October 2000. and in December 2000, Sun announced the Java API for XML Messaging (JAXM) and the Java API for XML Data Binding (JAXB). As of this writing, however, XML remains at the periphery of The J2EE F ramework (basic SAX and DOM APIs, and the use of XML for deployment descriptors). The parsers are there, and standard Java XML messaging and data binding APIs are in the works, but they need to be integrated seamlessly into the J2EE environment. XML .
Strategic PracticalitiesWhere does all this leave us in terms of enterprise application frameworks? Well, at a high level, we're all in a much better place-Microsoft is fixing its Web application environment, making it a peer (at the very least) to J2EE, so when dot-NET arrives we'll have two very capable development frameworks to choose from. Perhaps more importantly, Microsoft has pushed the envelope in terms of application services (especially XML support), and the company's put a new twist on portability with the language-independent CLR. These efforts have spurred Sun's efforts around XML support (as mentioned previously with it's recently-announced JAXM and JAXB efforts), and in other areas as well. and both Sun and Microsoft, through all their bickering, have gotten the developers and technology strategists talking about new perspectives on enterprise development.But at the end of the day, you have to decide which framework to adopt. Given all the technology issues I've discusse d, the path to a decision is fairly simple. In any significant development effort, whether you're a software product vendor, a consultant on a custom development engagement, an internal developer of Application Service Provider (ASP) offerings, or building the internal enterprise infrastructure for an organization, you need to decide who your target customers are (today and in the future), what platforms you need to support from a strategic level (today and in the future), and what framework provider you want to partner with TO PUSH Forward (Today and in The Future).
If you have the luxury of only supporting the Windows platform (with respect to both customers and internal development needs), and if you feel Microsoft is the right partner (for development tools, servers, administrative systems and so on) for your organization, then you have an easy decision indeed. Alternatively, if you have the luxury of defining a Web development practice based on a single language, and can not say with finality that Microsoft and Windows can be your sole vendor and platform, then you have an equally easy decision to make. Conversely, if you face the strategic need to support (or standardize on) Unix and other non-Windows servers, or if you want to leave your options open in other areas (tool vendors, application servers, component vendors and so on), then jump on the J2EE bandwagon. Alternatively, if supporting development in multiple languages is a strategic need of yours, and you can live with a single platform and tool vendor, then use dot-NET.Of course, very f ew groups or organizations find themselves in any of these neat compartments, but hopefully these examples will serve as markers on this slalom course. Perhaps we will reach the day when enterprise systems crafted in either of these frameworks can be easily and seamlessly integrated with each other . Until the, choose Your Steed Wisely and Charge Onward-TheRe IS An Interesting Road Ahead Either Way.