O'Reilly Network    


 Published on The O'Reilly Network (http://www.oreillynet.com/)
 http://www.oreillynet.com/pub/wlg/2253

The Pet Store.... Again

by Ted Neward
Nov. 4, 2002

I live in two worlds.

I've been writing Java code for over 6 years now, specifically in the back-end server space. (I was using the NetDynamics product as far back as late 1996, when JDK 1.0 as the norm.) I've been writing about Java since 1998, and teaching about Java since 1999. I've also been writing .NET code for over 2 years now, specifically in the back-end server space. I've been writing about .NET since 2001, and teaching about .NET for about the same amount of time. Living in both worlds gives me a really interesting perspective, both politically and technologically; I'm a member of the JSR-175 Expert Group, to bring metadata annotations into Java, and I'm writing a book on Rotor, the Shared Source .NET runtime implementation. I love Java, I love .NET. I want both to thrive, because the innovations produced as a result of competition between the two benefit us all.

Normally, I really really try to avoid the whole benchmarking thing--it's a black hole that ultimately does nobody any good. People ask me in my classes (J2EE or .NET, doesn't matter) which technology is faster, Java or .NET. I tell them that I've never run a benchmark, because I believe the variables between the two camps are too many and too diverse to accurately benchmark, and that ultimately it doesn't matter because the choice of which technology to use is usually made on a golf course or over a fancy dinner, not in a benchmarking lab. DevelopMentor, the company I teach for, went through this "should we do a benchmark to compare the two" discussion about two years ago, and we all almost unanimously voted against it, for many of the same reasons.

When Microsoft released their version of the Pet Store a year or so ago, I was moderately amused--they'd rewritten the sample to use what they believe to be .NET best practices (which at this point is realistically anybody's guess), and behold! Massive performance improvements. The Java community as a whole ridiculed the effort, and several J2EE app server vendors responded by writing their own versions of the Pet Store demo, and behold! Massive performance improvements. Nothing new here.

But now, The Middleware Company, a reputable Java and J2EE training and consulting company (and, I must, in the interests of full disclosure, point out, a rival to DevelopMentor) has taken the plunge and attempted to produce a benchmark that seriously compares J2EE and .NET on the subject of the Pet Store once again. They published their results last week, and, to put it politely, all Hell broke loose.

First and foremost, I want to point out that I deeply respect the pure cojones of The Middleware Company (TMC) in producing this--they knew, when they saw the results, what the reaction within the industry would be, and they published the results anyway. I have to believe that this was in the honest interests of trying to toe the careful line of honest reporting--either that, or TMC has decided to force themselves into bankruptcy. It simply makes no sense for them to do anything otherwise (unless they've suddenly decided to become a .NET training company, which I doubt). So I think it's important to give TMC some props on that score. I believe they did try to make it as fair of a benchmark as they could, and they did achieve a serious performance improvement (17 times better than Sun's original implementation, according to the report (p. 7). Whether they did everything they possibly could have done is another issue, addressed later.

In the meantime, however, it seems as if everybody within the industry, particularly the Java guys, have been leaping to their feet to decry the results of the benchmarks. In basketball, we'd be seeing a bench-clearing brawl right about now. More vitriolic poison has been slung between posters on message forums over this benchmark than in the last U.S. Presidential election--it's amazing.

As someone who lives and breathes in both camps, I feel compelled to offer my own spin on things, to anybody who's still listening. In particular, I want to address some comments made by Dion Almaer, in his OReilly weblog, and Rickard Oberg, in his online website review of the benchmark. I've never met either personally, but I have exchanged email with Rickard (a number of years ago). I deeply respect both.

Comments

Without further ado, let's get into this. As always, I welcome comments and criticisms of my criticism.

Summary

At the end of the day, however, I hope that this benchmark does a couple of things:
  1. Java developers, .NET is a serious contender and is here to stay. Simply calling Microsoft names and writing the derogatory "M$" everywhere doesn't erase the fact that Microsoft has produced a viable alternative to Java, particularly on the Win32 platform. Stop being silly and closing your eyes to this. Instead, do what Microsoft does so well, and steal from them: steal ideas, steal concepts, steal designs, then twist them around to make your Java apps faster. .NET doesn't provide any kind of support for entity beans? Ask yourself why that is. .NET doesn't provide any kind of support for object pooling? Ask yourself why that is. I'm not saying that everything Microsoft does is perfect--Windows DNA is a prime example of that--but don't lull yourself into complacency by simply chanting "Microsoft sucks" to yourself and ignoring what's going on over there. There's a lot of bright people there in Redmond, and they've been thinking about this problem a long time.
  2. .NET developers, don't be lulled into complacency, either. The various Java vendors are *not* going to take this benchmark laying down, and you can bet that the Java guys are going to come after it with both barrels blazing. In particular, there is a tremendous amount of good ideas that the J2EE world embraces that are somewhat awkward to do in .NET; one such case in point is the whole Model-View-Controller paradigm for building webapps. Pick up a Servlets/JSP book, and figure out how to bring that over to ASP.NET. Don't start thinking that you can just dribble SQL all over your .aspx pages and expect that the .NET runtime will somehow make your application "just run faster"--it isn't going to work.
  3. Java developers, this benchmark is essentially an indictment of EJB, not of Java. Demand to see a benchmark that doesn't use EJB in the middle, using stored procedures against the Oracle database, built in an intelligent fashion that doesn't include dead code or redundant transactional boundaries. Think you need EJB to work against simultaneous distributed databases? Think again--most servlet containers (the principal one I'm thinking of is Tomcat) support JTA, which means you can do distributed transactions against multiple databases directly from the servlet container. Think this means you're losing the benefits of connection pooling? Not at all--the servlet container naturally acts as a connection-pooling funnel, particularly when coupled with connection-pooling JDBC drivers. (The same, remarkably enough, can be said for .NET and COM+.)
  4. .NET developers, this benchmark is essentially an indictment of EJB, not of Java. Demand to see a benchmark that doesn't use EJB in the middle, so you can get a fair and unbiased comparison of how the Java bits work against the .NET bits. Be prepared to admit that there's really not a whole lot of difference between the two once we get down to that level.
  5. Everybody, step back for a second and realize that at the end of the day, IT DOESN'T MATTER. This benchmark only proves that .NET turned out to be faster for this application in this environment for this particular test. Is your application precisely similar, in both architecture and implementation, to the Pet Store? It's a hideous leap of logic to assume that "because the .NET implementation of the Pet Store runs faster in the lab, my online human resources system will run faster in our data center"; once the code diverges at all from the benchmark, entirely new variables come into question that can seriously affect the results.

To me, the verdict is clear: run your own benchmarks, form your own conclusions. It would be nice if we could find somebody who's completely neutral to run a benchmark, but what company exists today, working in both spaces (so as to provide equal degrees of expertise) that doesn't have ties to Microsoft or Sun/IBM/Oracle/etc? Let's forget the benchmarks, analyze the code to find out why they each performed the way they did, and apply the lessons to our own systems.

Ted Neward is an independent software development architect and mentor in the Sacramento, California area.

oreillynet.com Copyright © 2006 O'Reilly Media, Inc.