Rod Johnson holds a prominent status in the Java development community. He is the founder of the Spring Framework for Java, a consultant and author. He wrote the books, Expert One-on-One J2EE Design and Development and Expert One-on-One J2EE Development without EJB. He also is CEO of Interface21, an international consulting firm. Editor at Large Paul Krill spoke with Johnson during TheServerSide Java Symposium in Las Vegas last month about topics such as simplifying and open sourcing Java, aspect-oriented programming, the Spring Framework, and how .Net stacks up as a competitor to Java.
What obstacles do you see to simplifying Java programming and how much simplification does it need?
In terms of simplification, I think the Java language itself did a pretty good job of simplifying a lot of constructs, certainly compared to the history behind it with C++. And I think that [with] Java 5, the language level continues that. In terms of where we find the greatest complexity, it's really in the area of server-side Java, and I think we've made huge progress in the last few years towards POJO-based (Plain Old Java Objects) development. I think that certainly the reality is server-side Java development today is much simpler than it was with the original J2EE model.
What are the main benefits of aspect-oriented programming and why should developers hop on the bandwagon if they haven't already done so?
The main benefit of aspect-oriented programming is that it complements object-oriented programming. Object-oriented programming has spread into a very, very successful paradigm, and one of the great things about it is the way in which it helps you foster reuse and remove duplication.
So, for example, if you have an account class and you [extend] from that savings account, checking account, credit account, etcetera, you have a very nice way of using that hierarchy to encapsulate logic that you want to reuse. Where it does, fall down, however, [is] in addressing what we call crosscutting concerns.
Crosscutting concerns are pieces of functionality that may apply to a whole system that would, if they're implemented in the traditional object-oriented way, affect multiple classes and methods. Let's take, as an example, the notion of auditing. There is, of course, the ability to have helper functionality in a base class, like a base account class, that will, for example, run auditing behavior. But what happens if we say that every method that can lead to a change in the state of the savings account should be audited?
There is no way in classic OO-modeling to avoid duplication in doing that. You will end up with the auditing code scattered between multiple methods. And of course it gets much worse when you say that auditing should apply to savings accounts, that it also should apply to different areas of functionality, such as inventories, addresses, etc. The problem of duplication becomes still worse. So aspect-oriented programming introduces the concept of an aspect. An aspect really is a way of modularising the code that will apply a crosscutting concern. [With] the Spring Framework, the transaction management and security are delivered by an aspect approach, so users are not necessarily forced to explicitly work with OOP constructs, but they nevertheless benefit from this modularisation of code that would otherwise be scattered.
Explain your role in the development of the Spring Framework. And could you briefly compare Spring to other frameworks, such as JavaServer Faces and WebWork?
The Spring Framework grew out of my first book on J2EE, Expert One-on-One J2EE Design and Development, which was published in late-2002. That book really helped to start what we might call the lightweight revolution in J2EE. It really argued that the traditional model was way too complex, and with the book I actually published 30,000 lines of code, which was originally intended to show my view on how things could be done in a simpler way through an application framework.
But of course, many readers became very interested in this and quickly I was persuaded to make it an open-source project. So development started in earnest in early-2003. Compared to other frameworks, Spring really created a niche for itself. So Spring is what we call an application framework, and it actually addresses multiple architectural tiers. So if you look at frameworks [such as] Struts or WebWork, they more often than not just address one architectural layer. So Struts and WebWork are both web frameworks. Compared to JSF, Spring and JSF are not really in the same space. JSF is essentially a component model for rendering Web resources, whereas Spring is more a framework that aims to bring an overall structure and coherency to your application as a whole. So Spring actually can be used with JSF. Spring does provide its own MVC (Model-View Controller) web framework, which I guess can be regarded as being in the same space as Struts and WebWork, but on the other hand, Spring is a modular framework.
You once said the Java Community Process reminds you of an old Soviet-style planned economy. Could you elaborate on that?
I think [it was in] the traditional approach, and in fairness to the JCP, I think this has begun to change now. But the traditional approach involved a committee, which was more often than not dominated by vendors, defining essentially the programming model. The problem with this approach was that it really wasn't based on either competition or experience. So more often than not, you [found that] really quite complex programming models, such as the original EJB (Enterprise JavaBeans) programming model, were defined by groups of people who did not actually develop applications. So they developed servers. They were highly skilled and highly intelligent people, but that's not the same thing as being regularly exposed to what people were doing in banks and all the real businesses that actually used this software. So the reason that I referred to the notion of capitalism versus the Soviet system is that the effect of this was that there was something that was mandated. This was the way you were going to do it for the next few years. And it meant that if the approach was not a good approach, it would actually survive for a long time. And it also meant that there wasn't that much opportunity for the kind of innovation that we see, for example, in business or where you get a lot of competition forcing people to [lift] their [game] and innovate.
Do you believe that Java needs to be open sourced, as in Sun relinquishing control as the steward over it? What would be gained by that and what might the risks be?
I don't have a strong opinion on the issue of Java as a language. I do [quote] the old adage — if it ain't broke, don't fix it. I think Sun is actually doing a pretty good job with Java as a language, so while I think there are pretty strong arguments for open sourcing it, I think there's also a fairly strong argument that it's doing rather well so we should leave it alone. With respect to some other elements of the platform, I think that it probably is time to recognise that in particular open source is now playing a very significant role in innovating and defining the way people want to work. And I think we do have to think about whether the JCP in some areas maybe has a smaller role to play.
What would be gained and what would be risked if Java was open sourced?
I think the gain would be that perhaps. It would be possible for a number of fixes to go into the language. For example, there are a number of situations where there is an awareness that there are certain bugs in the platform. Mainly relatively minor, of course; I mean overall it's extremely stable. But nevertheless, I think you would very quickly see a large number of fixes, at probably a more rapid rate. So, for example, there's the Java Bug Parade; there's a number of issues that haven't been fixed for a number of years. I think they'd probably be fixed fairly quickly. You would probably also see maybe the emergence of other large companies besides Sun taking a very strong interest, and I think that would be a positive rather than a negative. In terms of what are the potential negatives, I think that if it were done carefully, there probably wouldn't be many potential negatives. I think it's vital that if there were an open source Java [and] the project was very tightly controlled, probably by some kind of non-profit or something, I think that it would definitely involve a degree of control in direction rather than say going to a model where you have a very large group of contributors checking in code all the time, which makes it hard to guarantee the stability of the platform.
By having some sort of control, you would prevent forking, correct?
I would have thought that forking would have been unlikely ... Forking is a pretty radical thing, and I would [think] that frankly if the project were healthy around an open source Java, a fork would just not be successful, so therefore the threat of a fork would not really be terribly significant.
That's an interesting question. I'm not sure that I have enough really recent practical experience to answer that. I do think that certainly a number of the things that are getting attention with AJAX are not new. I think that the branding, having an acronym around AJAX, suddenly [brought] back to the mainstream some things that had been discussed a number of years ago. There has been significant progress in browsers that are implementing the HTML constructs now, which makes AJAX more feasible. But certainly, I do not think it's a radical new concept.
What technologies might arrive to replace Java or supercede it?
That's a very interesting question, because if you look at the lifecycle of languages, clearly Java is a fairly mature language. Certainly, there seems to be a surge in interest in dynamic languages, languages such as Ruby, Python. I think that it's very important that the JVM (Java Virtual Machine) is distinguished from Java. So Java is probably always going to be the primary language that runs on the JVM, but I think we should realize that the Java platform could potentially encompass the choice of programming languages. There was a number of interesting developments such as Groovy, which came out of the Java community, which is a very concise and powerful language in many respects. There are also Java versions [or ports] of popular languages such as Ruby. There's JRuby. This is one of the things that we're trying to achieve in Spring 2.0. We've actually enabled now the Spring component model to span any language that runs on the JVM, so I actually gave an example yesterday using JRuby.There are a lot of interesting developments in bringing dynamic languages to the Java platform. I would also like to say in order for Java to remain strong, I think it's vital that innovation continues in the Java language. Although Java 5 was a significant step forward, it's very important that Java continues to evolve as a language. I think once it stops evolving, it will start to die.
To where would you see it evolving?
I think that will partly come out of experience of how people end up using dynamic languages, and also I think there has to be a period of consolidation after Java 5, because it is a major new release. I think thereafter we need to look very carefully at why people like dynamic languages and which of those capabilities we can bring that may be relevant to Java as a language itself.
An Apache official at the EclipseCon conference the other day said that eventually all software would be free, with vendors selling services. Do you agree?
I don't think we'll ever get to the position where all software is free. I think that there will always be market sectors where different forces apply, but I think there is an extremely powerful force towards moving in that direction. So I think that within a few years, the vast majority of software will be in that case, in that situation.
What is your impression of Microsoft .Net technologies?
I think .Net is a credible platform. It is very serious competition for enterprise Java technology. There's a number of interesting things that have been achieved in .Net. So, for example, the ability to run multiple languages on the .Net platform, and also they're doing some very interesting work around DSLs (domain-specific languages) and they are actually doing some very interesting innovation in the C# language itself.