Anyone who's had anything to do with computers in the '90s knows that the Internet is all the rage. The immense growth of this global computer network has not only created a handy way to download files and information but has also sparked major controversies over freedom of speech, copyright law, and computer security. Hardly a day goes by without the Internet making the news.
But not all Internet activity is steeped in controversy. One of the more positive Internet newsmakers has been the release of Java, a computer programming language that enables folks like you and me to easily create applications that can be used across the Internet without worrying about platform compatibility or network security. The two types of Java applications-applets for use within World Wide Web pages and stand-alone Java applications-are guaranteed to do more to liven up the World Wide Web than even the most heated controversy.
Java, however, was conceived long before its suitability for the Internet was noted and taken advantage of. You may be surprised to learn that Java was developed for a very different use. In fact, "Java" isn't even the language's original name. In this chapter, you'll get a quick look at Java's history, as well as learn why Java is an excellent tool for creating Internet applications.
Although Gosling didn't care for the complexity of languages such as C++, he did like the basic syntax and object-oriented features of the language. So when he sat down to design his new language, he used C++ as its model, stripping away all the features of C++ that made that language difficult to use with his consumer-electronics projects. When Gosling completed his language-design project, he had a new programming language that he named Oak. (The story goes that the name Oak came to Gosling as he gazed out his office window at an oak tree.)
Oak was first used in something called the Green project, wherein the development team attempted to design a control system for use in the home. This control system would enable the user to manipulate a list of devices, including TVs, VCRs, lights, and telephones, all from a hand-held computer called *7 (Star Seven). The *7 system featured a touch-sensitive screen that the owner used to select and control the devices supported by the control.
The next step for Oak was the video-on-demand (VOD) project, in which the language was used as the basis for software that controlled an interactive television system. Although neither *7 nor the VOD project led to actual products, they gave Oak a chance to develop and mature. By the time Sun discovered that the name "Oak" was already claimed and they changed the name to Java, they had a powerful, yet simple, language on their hands.
More importantly, Java was a platform-neutral language, which meant that programs developed with Java could run on any computer system with no changes. This platform independence was attained by using a special format for compiled Java programs. This file format, called byte-code, could be read and executed by any computer system that has a Java interpreter. The Java interpreter, of course, must be written specially for the system on which it will run.
In 1993, after the World Wide Web had transformed the text-based Internet into a graphics-rich environment, the Java team realized that the language they had developed would be perfect for Web programming. The team came up with the concept of Web applets, small programs that could be included in Web pages, and even went so far as to create a complete Web browser (now called HotJava) that demonstrated the language's power.
In the second quarter of 1995, Sun Microsystems officially announced Java. The "new" language was quickly embraced as a powerful tool for developing Internet applications. Netscape Communications, the developer of the popular Netscape Navigator Web browser (Figure 1.2), added support for Java to its new Netscape Navigator 2.0. Other Internet software developers are sure to follow suit, including Microsoft, whose Internet Explorer 3 (currently in beta) offers Java support. After more than five years of development, Java has found its home.
According to Sun Microsystems, Java is "simple, object-oriented, statically typed, compiled, architecture neutral, multi-threaded, garbage collected, robust, secure, and extensible." That's a mouthful, but this description of Java probably doesn't help you understand the language much. The following list of Java's attributes, however, should clear out some of the cobwebs:
But not all Internet activity is steeped in controversy. One of the more positive Internet newsmakers has been the release of Java, a computer programming language that enables folks like you and me to easily create applications that can be used across the Internet without worrying about platform compatibility or network security. The two types of Java applications-applets for use within World Wide Web pages and stand-alone Java applications-are guaranteed to do more to liven up the World Wide Web than even the most heated controversy.
Java, however, was conceived long before its suitability for the Internet was noted and taken advantage of. You may be surprised to learn that Java was developed for a very different use. In fact, "Java" isn't even the language's original name. In this chapter, you'll get a quick look at Java's history, as well as learn why Java is an excellent tool for creating Internet applications.
The Java Story
Back in 1990, a gentleman by the name of James Gosling was given the task of creating programs to control consumer electronics. Gosling and his team of people at Sun Microsystems started designing their software using C++, the language that most programmers were praising as the next big thing because of its object-oriented nature. Gosling, however, quickly found that C++ was not suitable for the projects he and his team had in mind. They ran into trouble with complicated aspects of C++ such as multiple inheritance of classes and with program bugs such as memory leaks. Gosling soon decided that he was going to have to come up with his own, simplified computer language that would avoid all the problems he had with C++.Although Gosling didn't care for the complexity of languages such as C++, he did like the basic syntax and object-oriented features of the language. So when he sat down to design his new language, he used C++ as its model, stripping away all the features of C++ that made that language difficult to use with his consumer-electronics projects. When Gosling completed his language-design project, he had a new programming language that he named Oak. (The story goes that the name Oak came to Gosling as he gazed out his office window at an oak tree.)
Oak was first used in something called the Green project, wherein the development team attempted to design a control system for use in the home. This control system would enable the user to manipulate a list of devices, including TVs, VCRs, lights, and telephones, all from a hand-held computer called *7 (Star Seven). The *7 system featured a touch-sensitive screen that the owner used to select and control the devices supported by the control.
| NOTE |
The *7 screen display featured a number of animated figures, of which Duke (now the little guy considered to be the Java mascot) was one. Once you get involved with Java, you're liable to see a lot of Duke, who pops up on the Sun Microsystems Web site (Figure 1.1), and who is featured in some of Sun's sample Java applets. |
The next step for Oak was the video-on-demand (VOD) project, in which the language was used as the basis for software that controlled an interactive television system. Although neither *7 nor the VOD project led to actual products, they gave Oak a chance to develop and mature. By the time Sun discovered that the name "Oak" was already claimed and they changed the name to Java, they had a powerful, yet simple, language on their hands.
More importantly, Java was a platform-neutral language, which meant that programs developed with Java could run on any computer system with no changes. This platform independence was attained by using a special format for compiled Java programs. This file format, called byte-code, could be read and executed by any computer system that has a Java interpreter. The Java interpreter, of course, must be written specially for the system on which it will run.
In 1993, after the World Wide Web had transformed the text-based Internet into a graphics-rich environment, the Java team realized that the language they had developed would be perfect for Web programming. The team came up with the concept of Web applets, small programs that could be included in Web pages, and even went so far as to create a complete Web browser (now called HotJava) that demonstrated the language's power.
In the second quarter of 1995, Sun Microsystems officially announced Java. The "new" language was quickly embraced as a powerful tool for developing Internet applications. Netscape Communications, the developer of the popular Netscape Navigator Web browser (Figure 1.2), added support for Java to its new Netscape Navigator 2.0. Other Internet software developers are sure to follow suit, including Microsoft, whose Internet Explorer 3 (currently in beta) offers Java support. After more than five years of development, Java has found its home.
Introducing Java
By now, you may be curious why Java is considered such a powerful tool for Internet development projects. You already know that Java is a simplified version of C++. Anyone who has struggled with learning C++ knows that the key word in the previous sentence is "simplified." C++ added so much to the C language that even professional programmers often have difficulty making the transition.According to Sun Microsystems, Java is "simple, object-oriented, statically typed, compiled, architecture neutral, multi-threaded, garbage collected, robust, secure, and extensible." That's a mouthful, but this description of Java probably doesn't help you understand the language much. The following list of Java's attributes, however, should clear out some of the cobwebs:
- Simple. Java's developers deliberately left out many of the unnecessary features of other high-level programming languages. For example, Java does not support pointer math, implicit type casting, structures or unions, operator overloading, templates, header files, or multiple inheritance.
- Object-oriented. Just like C++, Java uses classes to organize code into logical modules. At runtime, a program creates objects from the classes. Java classes can inherit from other classes, but multiple inheritance, wherein a class inherits methods and fields from more than one class, is not allowed.
- Statically typed. All objects used in a program must be declared before they are used. This enables the Java compiler to locate and report type conflicts.
- Compiled. Before you can run a program written in the Java language, the program must be compiled by the Java compiler. The compilation results in a "byte-code" file that, while similar to a machine-code file, can be executed under any operating system that has a Java interpreter. This interpreter reads in the byte-code file and translates the byte-code commands into machine-language commands that can be directly executed by the machine that's running the Java program. You could say, then, that Java is both a compiled and interpreted language.
- Multi-threaded. Java programs can contain multiple threads of execution, which enables programs to handle several tasks concurrently. For example, a multi-threaded program can render an image on the screen in one thread while continuing to accept keyboard input from the user in the main thread. All applications have at least one thread, which represents the program's main path of execution.
- Garbage collected. Java programs do their own garbage collection, which means that programs are not required to delete objects that they allocate in memory. This relieves programmers of virtually all memory-management problems.
- Robust. Because the Java interpreter checks all system access performed within a program, Java programs cannot crash the system. Instead, when a serious error is discovered, Java programs create an exception. This exception can be captured and managed by the program without any risk of bringing down the system.
- Secure. The Java system not only verifies all memory access but also ensures that no viruses are hitching a ride with a running applet. Because pointers are not supported by the Java language, programs cannot gain access to areas of the system for which they have no authorization.
- Extensible. Java programs support native methods, which are functions written in another language, usually C++. Support for native methods enables programmers to write functions that may execute faster than the equivalent functions written in Java. Native methods are dynamically linked to the Java program; that is, they are associated with the program at runtime. As the Java language is further refined for speed, native methods will probably be unnecessary.
- Well-understood. The Java language is based upon technology that's been developed over many years. For this reason, Java can be quickly and easily understood by anyone with experience with modern programming languages such as C++.
No comments:
Post a Comment