【正文】
The designers did not, however, attempt to fix all of the clumsy features of C++. For example, the syn tax of the switch statement is unchanged in Java. If you know C++, you will find the tran sition to the Java syntax easy. If you are used to a visual programming environment (such as Visual Basic), you will not find Java simple. There is much strange syntax (though it does not take long to get the hang of it). More important, you must do a lot more programming in Java. The beauty of Visual Basic is that its visual design environment almost automatically pro vides a lot of the infrastructure for an application. The equivalent functionality must be programmed manually, usually with a fair bit of code, in Java. There are, however, thirdparty development environments that provide “draganddrop”style program development. Another aspect of being simple is being small. One of the goals of Java is to enable the construction of software that can run standalone in small machines. The size of the basic interpreter and class support is about 40K bytes。 adding the basic stan dard libraries and thread support (essentially a selfcontained microkernel) adds an additional 175K. This was a great achievement at the time. Of course, the library has since grown to huge proportions. There is now a separate Java Micro Edition with a smaller library, suitable for embedded devices. Object Oriented Simply stated, objectoriented design is a technique for programming that focuses on the data (= objects) and on the interfaces to that object. To make an analogy with carpentry, an “objectoriented” carpenter would be mostly concerned with the chair he was building, and secondarily with the tools used to make it。 a “nonobject oriented” carpenter would think primarily of his tools. The objectoriented facilities of Java are essentially those of C++. Object orientation has proven its worth in the last 30 years, and it is inconceivable that a modern programming language would not use it. Indeed, the objectoriented features of Java are parable to those of C++. The major difference between Java and C++ lies in multiple inheritance, which Java has replaced with the simpler concept of interfaces, and in the Java metaclass model (which we discuss in Chapter 5). NOTE: If you have no experience with objectoriented programming languages, you will want to carefully read Chapters 4 through 6. These chapters explain what objectoriented programming is and why it is more useful for programming sophisticated projects than are traditional, procedureoriented languages like C or Basic. NetworkSavvy Java has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP. Java applications can open and access objects across the Net via URLs with the same ease as when accessing a local file system. We have found the working capabilities of Java to be both strong and easy to use. Anyone who has tried to do Inter programming using another language will revel in how simple Java makes onerous tasks like opening a socket connection. (We cover working in Volume II of this book.) The remote method invocation mechanism enables munication between distributed objects (also covered in Volume II). Robust Java is intended for writing programs that must be reliable in a variety of ways.