3. Computers, Objects, and Java

3.7. Why Java?

Originally named “Oak” after a tree outside the office of its developer, James Goslin, Java is a relatively young programming language. It was initially designed by Sun Microsystems in 1991 as a language for em- bedding programs into electronic consumer devices, such as microwave ovens and home security systems. However, the tremendous popularity of the Internet and the World Wide Web (WWW) led Sun to recast Java as a language for embedding programs into Web-based applications. As you recall, the Internet is a global computer network, and the WWW is that portion of the network that provides multimedia access to a vast range of information. Java has become one of the most important languages for Web and Internet applications.

Java has also generated significant interest in the business community, where it is has proved to have tremendous commercial potential. In addi- tion to being a useful tool for helping businesses to promote their products and services over the Internet, Java is also a good language for distribut- ing software and providing services to employees and clients on private corporate networks or intranets.

Because of its original intended role as a language for programming mi- croprocessors embedded in consumer appliances, Java has been designed with a number of interesting features:

Java is object oriented. Object-oriented languages divide programs into separate modules, called objects, that encapsulate the program’s data and operations. Thus, object-oriented programming (OOP) and

object-oriented design (OOD) refer to a particular way of organizing pro- Object-oriented Languages

 

 

 

 

 

 

 

 

Platform independence


grams, one which is rapidly emerging as the preferred approach for building complex software systems. Unlike the C++ language, in which object-oriented features were grafted onto the C language, Java was designed from scratch as an object-oriented language.

Java is robust, meaning that errors in Java programs don’t cause system crashes as often as errors in other programming languages. Certain features of the language enable many potential errors to be detected before a program is run.

Java is platform independent. A platform, in this context, is just a particu- lar kind of computer system, such as a Macintosh or Windows system. Java’s trademark is “Write once, run anywhere.” This means that a Java program can be run without changes on different kinds of computers. This is not true for other high-level programming languages. This porta- bility – the ability to run on virtually any platform – is one reason that Java is well suited for WWW applications.

Java is a distributed language, which means that its programs can be designed to run on computer networks. In addition to the language it- self, Java comes with an extensive collection of code libraries—software that has been designed to be used directly for particular types of applications—that make it particularly easy to build software systems for the Internet and the WWW. This is one of the reasons why Java is so well suited for supporting applications on corporate networks.

Java is a secure language. Designed to be used on networks, Java con- tains features that protect against untrusted code—code that might in- troduce a virus or corrupt your system in some way. For example, once they are downloaded into your browser, Web-based Java pro- grams are prevented from reading and writing information from and to your desktop computer.

 

Despite this list of attractive features, perhaps the best reason for choosing Java as an introductory programming language is its potential for bring- ing fun and excitement into learning how to program. There are few other languages in which a beginning programmer can write a computer game or a graphically based application that can be distributed on a Web page to just about any computer in the world. The simplicity of Java’s design and its easily accessible libraries bring such accomplishments within reach of the most novice programmers.

For example, we will work on projects throughout the text that involve games and puzzles. We start out in Chapter 2 by designing very simple games that involve storing and retrieving data. As we learn more sophisti- cated programming techniques, we gradually build more complexity into the games and puzzles. For example, we learn how to create interactive, two-person games in Chapter 4. In Chapter 8, we develop some games and puzzles that are played on virtual game boards. Finally, in Chapter 14 we learn how to introduce games with multiple players on different com- puters. To get a look at where we are headed you might want to visit the authors’ companion Web site:

,,

 

 

J