Friday, October 19, 2007

Java: A Retrospective

It was 1995 and C++ was the language of choice for building large-scale software systems. C++ was a powerful object-oriented programming language, the successor of widely used procedural language called C. But not only was C++ powerful, it was also quite complicated. Seasoned programmers enjoyed the intricacies and the possibilities, but newbies would get burned after the first mishandled copy constructor.

Enter Java - a language of great elegance, power and, most importantly, simplicity. Designed by James Gosling and his team at Sun Microsystems, Java became a phenomenon that won hearts and minds, changed the rules of enterprise programming and seriously wounded Microsoft. Yet despite its glory, Java lost one of the most important battles - the battle for the web browser. In this post we look at what happened to Java in the last decade, from its glorious rise, to market politics, to the battle for the browser.

The Beauty Of Java

The first great thing about the core Java language was that it was simple. The creators of the language made assumptions and compromises and decided to take away some power from programmers, but the benefits by far outweighed the limitations. The second great thing was the virtual machine. To make a C++ program run on another platform required a lot of effort. Java programs, on the other hand, were portable automatically.

Then there were the libraries. Java's libraries made a huge impact because they shifted developer focus from worrying about the infrastructure to worrying about the application. Some of the earlier Java libraries truly set the bar for innovation, flexibility and utility. For example, the JavaBeans framework showed that component development can be easy (unlike COM and ActiveX). And the collections framework delivered reusable and extensible standard data structures and algorithms.

But probably the most important thing that Java taught many of us was to think about interfaces. The power of any object-oriented language is abstraction, and by emphasizing the interface, Java brought that power forward. Debunking the inheritance myth, Java named the interface to be a king of object-oriented programming.

Java's Enterprise Ambitions

As Java's popularity grew, so did the ambitions of its creators. Sun wanted Java everywhere: on the web, on the desktop, on mobiles and in the enterprise. The enterprise market looked particularly attractive because Sun would have the opportunity to sell its servers as well. Thus was born J2EE - a powerful infrastructure for building large-scale enterprise applications. Unfortunately, unlike the earlier Java libraries J2EE was quite complicated and even rather cumbersome.

Nevertheless J2EE gave rise to numerous standards, including probably the most important one - the modern application server. In a rather unexpected turn of events competitors like BEA, IBM, Oracle and Sun converged to create a set of standards that benefited first and foremost, the customers. All this was accomplished though the Java Community Process (JCP) - an industry round table for generating standard Java specifications.

The Java Community Process

Since its early days, the software community has lacked standards. In the 1980s and early 1990s consulting companies made a fortune building adapters that transformed output from one application into the input for another. Among the remarkable things that Sun managed to do with Java was introduce a process for generating industry-wide standards.

In a brilliant move, Sun shared its baby with everyone by inviting people to participate in the Java Community Process. The process consisted of phases, starting with the introduction of a new specification. If the need was established and approved, the draft and review phase focused on generating the first version of the spec and doing a public review. Anyone could provide feedback during the process, and then a group of authors would incorporate it into the draft.

IBM Hijacks Java With Eclipse

Sun has done many wonderful things with Java, but it also fell short at a few critical moments in history. First, it was a shame when Java was running faster on Windows than on Solaris. Their case for selling Sparcs as machines optimized for Java fell through. Sun recovered, but too late for people to buy into the benefits. Next, Sun did not develop a serious Java Integrated Development Environment (IDE) until late in the game.

IBM took advantage of this mistake and released a product ironically called Eclipse. This open source IDE allowed IBM to not only take over the basic development shell, but also release and distribute its own version of Java. IBM then made another clever move: it added standard development applications including testing tools, profiling tools, version control, etc. to Eclipse. And all of this it gave away free. With this move, IBM effectively cornered the developer tools market and cleared the path for selling more Web Spheres (IBM Application Servers) and Blades (IBM Servers).

Java Loses The Desktop And The Browser

Just like IBM out-maneuvered Sun, so did Microsoft. Microsoft has long maintained that Java is slow. Perhaps it was in the early days, but certainly that is no longer true. In fact, in most cases it runs as fast as native applications because of just in time compilation and various other optimizations. But Microsoft stuck to its guns, saying continuously that Java was slow, and added that Java user interfaces were also poor.


The image above is from Swing, written by Information Laboratory in 2003, and shows that Swing can draw its UI with thousands of objects.

Unfortunately for Java its first UI toolkit, AWT, was indeed not up to par. Eventually Sun came out with Swing, which was a superb UI framework; much faster than its predecessor and capable of creating the same kind of applications as Microsoft's tools. However, the myth had already been spread and middle management throughout the country trumpeted Microsoft's tune: Java was not good for the desktop.

And then there was the applet fiasco. Java applications where little applets that everyone grew to hate, thanks to their initial slowness and later inertia. Because of people's hatred for applets, Java lost the battle for being the programming language inside the browser.That loss is huge, given that the web is becoming more and more ubiquitous. What's sad is that Java lost to JavaScript (which has nothing to do with Java) and Flash - both inferior programming languages. The irony, of course, is that Java started with the web in mind.

The Cost Of Language Politics

There are great lessons to be learned from Java's story. The first is the lesson of simplicity and elegance. Java taught us that software can be simple to write. But another side of the Java story is about politics. Java won over people's hearts and minds and that alone made it a desirable target. IBM and Microsoft, both companies that have controlled dominant programming languages at different times in their histories, understood the value of Java and went after it. IBM executed perfectly. Microsoft pushed as hard as it could to block Java from the desktop and from the browser and succeeded.

The problem with politics, though, is that it's the people that get hurt, not the politicians. The fact is that AJAX, which has received a ton of positive press over the past couple of years, is a hacky, inelegant technology that pales in comparison to what exists in Java. If Java was part of the browser, it could manipulate HTML/DOM in exactly the same way that JavaScript does. But with Java we would get a first class programming language, a set of standards, robust libraries and a wide range of development tools. Alas, that's not to be.

Conclusion

The first decade of Java is a history of rapid rise and wide adoption. It is also a history of political battles and wrong choices made for the sake of marketing.

It is difficult to justify using inferior languages and tools to develop modern software. Java has come a long way and to throw it away would be a big mistake. Before inventing new languages and re-inventing new ways of doing things, the industry should pause and re-think the fate of Java in the browser.

This is sure to be a contentious post with people falling on both sides of the fence. Please, do not hold back, bare it all! Let's have some great discussion on this issue - leave your thoughts in the comments below.

No comments: