Java's sudden appearance and rapid rise to prominence on the software scene are nothing short of remarkable, and the excitement doesn't look like it's going to wear off soon. Making predictions about something that's moving so quickly is hard. Clearly, Java will be genuinely important, not just a momentary fad. Beyond that, little is certain.
Nevertheless, Tricks of the Java Programming Gurus would not be complete if it didn't contain a discussion of the possibilities for Java's future. A book for Java gurus needs to address more than just Java itself; it also needs to address the bigger picture of Java, its relationship to the current shape of the software industry, and the ways that it challenges the status quo. After all, Java's future depends in large part on programmers, how programmers view Java, and what sorts of new applications programmers can build with it. If programmers use Java to develop slightly improved versions of the same old programs, Java might still be a real success, but it will fall short of its true potential.
This book is full of useful tricks, techniques, and tips, but all the authors have also tried to include quite a few ideas for useful Java applets, applications, classes, and class libraries. Because of its unique combination of features, Java makes it possible (even easy, in some cases) to write entirely new kinds of applications that would be impossible (or prohibitively difficult) with more conventional languages. Ideas and suggestions for such programs are offered throughout this book.
This concluding chapter is devoted to the bigger questions:
Java might be the most-hyped technology ever. Java certainly cannot live up to all the claims and expectations, but it's impossible to say how close it might come. Java really isn't a huge technological leap-from a technical perspective, the only thing about Java that's really new is the combination of features all in one place. Java is definitely not the "silver bullet" that will finally tame the growing complexity of software.
On the other hand, Java is far more than "just another language." It's very unusual to see a technology that stirs such excitement both at the highest levels of management and in the trenches among working programmers. Interestingly, a lot of the excitement seems to stem from something deeper than the language features. As corny as it might sound, many people, especially programmers, are excited about Java because of the ideals it seems to represent.
Java's design, in my opinion, reflects two ideals, and in many ways the features that have caused all the excitement are the ones that sprang from those ideals. Accordingly, it's worth taking a page or two to spell them out. Naturally, I can't speak for the entire Java community, and I certainly can't speak for Java's designers, so please take this section as one person's view of the ideals of Java.
When companies first became interested in "open systems" as an alternative to the proprietary computer systems that they found themselves harnessed to, the very term carried a lot of power. Systems could be open-documented, compatible, cooperative. All the interest in open systems has brought some very real benefits, but the words don't really have the same ring anymore because they've been used as marketing buzzwords to describe systems that aren't really very "open" at all.
Java really is an open system. The language implementation is available for all to inspect, and the specification is published so that others can reimplement Java from scratch if they want. All the system documentation is available on the Web.
Java is open in other ways, too. It encourages and empowers developers to write open software systems of their own. The HotJava Web browser showcases this particular Java ideal: it's an application that is carefully written so that it can be extended and improved by anybody, dynamically, over the network.
The Java library provides examples and support for developers
who want to build open applications. The classes contain special
comments that can be used to generate hypertext documentation
automatically (see Chapter 18, "Developing
Database Applications and
Applets"). Factory objects (Chapter 17,
"Network-Extensible Applications with Factory Objects")
provide a powerful technique for making libraries extensible,
and Java's security features (Part 6, "Security") enable
extensions to be fetched from the network without fear.
Another aspect of Java's openness is its commitment to platform independence. Java now runs on 32-bit Windows systems, Macs, most UNIX systems, and OS/2, and it will soon run on 16-bit Windows systems and several less prominent platforms. No implementation dependencies are allowed by the Java language specification, and the Java bytecode format is completely portable.
Finally, Java's openness is reflected in its support for the Unicode international character set. Even though the current tools don't completely implement that support, the inclusion of Unicode support in the language specification and the library interfaces is an important statement. Future Java tools that do support Unicode properly will make it easier than ever before to write truly international applications.
Java is true to the ideal of open systems.
People have been talking about reusable software for years, but programmers are still reinventing the wheel, every minute of every day. Why should Java be any different?
Most object-oriented languages have software reusability as a goal, and Java is no different. But Java has some unusual features beyond typical object-orientation that facilitate code reuse. (As usual, the individual features aren't really new, but the combination is.)
First among them are Java's platform independence and the portable bytecode format. A Java class can be compiled once, on one machine, and then used on any system that supports Java. This capability reduces the cost of reuse.
The Java documentation conventions and the javadoc tool also help. One of the most frequent barriers to reuse is poor documentation: unless you wrote the class yourself, you don't really know what it does. Java's support for good class documentation doesn't magically solve the problem, but the support makes it easier for programmers to provide useful documentation for their class libraries.
The combination of language safety and exception handling takes some of the worry out of code reuse because it limits the damage that a third-party class can do in your program.
The final item on the list is the really unusual one. The combination of Java's security features and built-in networking facilities can ease many of the inconveniences of reuse. Packaging is a big obstacle to effective reuse. You don't want to choose (and pay for) a class library before you understand your needs for your project. On the other hand, when the need arises, seeking out a library that has the kind of class you need takes some work, and then you must purchase the whole library. Later in the project, you might realize the need for a different kind of class that isn't a part of the library you bought. Often, just writing a new version of the class is easier, especially because most existing commercial class libraries provide fairly simple classes.
The process would be easier if you could purchase classes individually or (possibly better yet) pay for them on a per-use basis. Java permits an application to load individual classes from the network, thus paving the way for such fine-grained reuse. Additionally, the suggested convention (detailed in the Java language specification) for allocating unique class names makes use of the Internet host naming system, so it might someday be possible to find a class on the Internet based solely on the full class name. Big problems still exist, of course, but the possibility is fascinating in its potential.
Even if you don't have plans to make your Java classes available to others, paying attention to reusability is worthwhile. Try to write generalized classes that can be useful in a variety of situations. Provide for extensibility using factory objects and dynamically loaded classes, where appropriate. Document the class interface. Put some thought into error handling: try to solve the problem, if possible, rather than just throw an exception; when you have to throw an exception, use one that is really appropriate for the error condition; and make sure that exceptions are declared as a part of a method's interface.
All programming languages have communities of users. Often they are very close-knit communities, with user groups that share ideas and cooperate. Such communities help a language evolve to meet new challenges or to correct deficiencies. A close-knit language community can make a strong contribution to the success of a language.
When a language becomes widely used as quickly as Java has, the user community is especially important. The language's designers need feedback to understand the weak points and suggestions for how to strengthen them. New programmers need help to learn the ropes. Most importantly, during the initial period when the standard libraries are being improved and expanded, cooperation is necessary to converge on a single, versatile solution, rather than a host of different, weaker alternatives.
In this respect, Java has the advantage of being strongly tied to the Internet. For several reasons, most Java developers have good Internet access. The Net makes it easy for Java users from all over to find others with similar interests, share experiences, and cooperate to meet new goals. The Usenet newsgroup devoted to Java, comp.lang.java, is extremely active (so active that a proposal is under consideration to split it into eight separate groups, to help manage the traffic). Mailing lists are devoted to several special topics including a Java interface to OpenDoc, a MIDI library, a VRML library, and ports to various different machines and operating systems. JavaSoft maintains a Web page titled "The Java Developer Community" that contains pointers to newsgroups, mailing lists, and regional user groups related to Java. The URL is http://www.javasoft.com/aboutJava/community.html. Another useful resource is Gamelan's Java projects page, at http://www.gamelan.com/pages/Gamelan.programming.projects.html.
If you are using Java in your work, or plan to, it's in your own interest to help Java succeed. The existence of a large body of programmers who know the language is important to many companies who are wary of adopting a language if programmers are difficult to find. When more companies adopt the language, more opportunities are created for programmers.
Java's user community is strong and growing. If Java is important to your work, try to find the time to participate. Make use of Java resources on the Internet. When you can't figure out something, ask the question-someone will probably answer, and good questions help the community to recognize confusing issues that need to be addressed. When you learn more, help novices who are following in your footsteps. Offer your input on the design of new libraries and facilities that you hope to use.
Consider making your classes available for others to use, either freely or for a fee. Especially now, in the early days of Java, the entire Java community is trying to quickly build a polished language system, an extensive library, and a mature body of techniques and expertise from a standing start. A great deal of sharing and cooperation are going on, and everyone is reaping the benefits. If possible, give something back. If, in the course of your work, you develop something (even just an idea or a technique) that you find useful but that probably isn't the linchpin of your fortune, think about sharing it with the Java community. You certainly don't have to give it away for it to be a contribution. If you have Java classes that you think people will pay to use, try selling them! You might save people some time and effort, and you'll be encouraging the growth of a market for reusable Java classes. Everybody wins.
There's room for both competition and cooperation in the Java community.
Java opens a lot of doors. No development environment has ever combined so many good things in one package. Java is
Work is in progress to add several other items to that list:
All these characteristics, used together, amount to far more than their sum. Nevertheless, revolutionary new Java applications won't build themselves.
The really good Java applications will be the ones that take the best advantage of the things that make Java special-both the details and features discussed throughout this book and the ideals described at the start of this chapter. But that description is not really helpful because it emphasizes the building blocks without providing a useful picture of the building. It would be better to look at three of the kinds of applications you could build with those tools.
Extensible applications can download extensions dynamically, to provide new functionality. These applications gain value through the efforts of third-party developers who provide useful extensions. Netscape's applet facility represents a simple kind of extensibility, whereas HotJava's content handlers and protocol handlers show more of the potential.
Applet platforms provide an execution environment where applets can be fetched and run by a user on demand-sort of like the native operating system but with Java's additional benefits. With flexible security policies, applets can begin taking the place of some smaller, infrequently used applications.
Applications that exploit the network can provide additional functionality, larger template and media libraries, better documentation, and easy collaboration among other users of the same application. Tim Berners-Lee, the creator of the World Wide Web, has predicted (and hoped) that eventually Web browsers will cease to be the main interface to the Web. He feels that the Web will become a resource that is used by most programs, the same way that programs currently use local system resources like files. Web browsers will still have their place, but they will be used primarily for viewing information (just as most operating systems today come with a simple program for viewing text files), and they will be called upon by other applications to display HTML and other Web documents as needed. Java is the ideal language for writing those next-generation Web-aware applications.
Set your sights high-aim for applications that really exploit Java's potential. One of the goals of this book has been to provide pointers toward the new kinds of applications that might arise, to help developers get the most out of Java. Take these tricks, build on them, and add more of your own. Java has tremendous promise, and it's up to application developers to make that promise a reality.