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.