What Java is


Now that we know Java's roots, let's talk about what Java is and what it can do. When the developers at Sun were creating Java, they had certain design guidelines in mind about the type of language they wanted to create. This section describes those concepts, giving you a feeling for the overall design philosophy of the language, what the developers did, and why. This section also lists some of the many advantages of Java.

Simple and Familiar

The creators of Java wanted the language to be simple and familiar. Java is based on C and C++ and borrows much in the way of basic syntax from those languages. The developers wanted to make Java a simple language by removing some of the complex elements of C and C++ that were potentially more trouble than they were worth. Programming entities not supported by Java include multiple inheritance, operator overloading, and publicly accessible pointers.

One criterion for removing elements was to minimize redundancy. C and, later, C++ evolved in a somewhat unstructured manner leading to overlapping features. Java tried to eliminate as much redundancy as possible while adding important features missing from C and C++.

Object Oriented

Java was designed from the ground up as a fully object-oriented programming language. The object-oriented paradigm has become the model of choice for modern programming languages in that it supports the needs of client/server and distributed software. Objects have portability and persistence. They can be created in one location and sent over a network connection to another location to be used or stored for future use. Java supports the object-oriented characteristics of encapsulation, inheritance, and polymorphism. These concepts are explained in more detail in Chapter 5.

Interpreted and Platform Neutral

The Internet was a major impetus in the development of Java. There was a need to be able to transmit applications from one machine to another over the Internet and there was no guarantee that the machines would be using the same operating system. When a Fortran, C, or C++ code is compiled and linked on a given system, the result is an executable file that can usually be run only on that system. You can't compile a program on a Microsoft Windows machine and run the executable under the Macintosh operating system, for instance. The implementation of many fundamental data types is machine and operating system dependent.

The designers of Java set out to develop a platform-independent language. When Java source code is compiled, the result is not a standard executable. Instead, what is produced is called bytecode. Bytecode, as the name would suggest, is a series of bytes that correspond to machine opcode instructions. A Java program is executed by sending its bytecode to the Java runtime system, which is called the Java Virtual Machine or JVM. The JVM interprets the bytecode and converts the bytes back into machine instructions. Because a Java program is run through a JVM interpreter, Java is known as an interpreted language.

There are many varieties of JVMs but all of them must adhere to a strictly defined specification. This ensures that bytecode generated on any machine running any operating system can be interpreted by a JVM on any other machine. A Java program can be compiled on a Windows machine and its bytecode can be sent over the Internet to a Linux box that will happily run the application.

Robust

Robustness, the ability of a program to run with low probability of a crash, is an increasingly important concern in the age of distributed and network applications. The Java compiler performs an extensive check for syntax- related errors and warnings, so problems can be identified before the program is deployed. Java is a strongly typed language. The type of each variable and parameter must be explicitly declared. This avoids type mismatch or casting errors.

Another big difference between C, C++, and Java is that the Java memory model precludes the possibility of overwriting locations in memory. This is due in part because Java does not support publicly accessible pointers. The compiler will also check array indices and will not permit a value that is out-of-bounds. Java has a sophisticated exception handling capability built into the language, so exceptions that would otherwise cause program termination can be dealt with.

Secure

With the rise of distributed and Web-based applications, security has become more and more important in modern software design. The Java compiler and runtime have built-in features to prevent application programmers from writing subversive code. One security enhancement is that Java does not support publicly accessible pointers. Because memory allocation is handled exclusively by the JVM, programmers cannot forge or manufacture pointers to memory locations. Because Java uses late binding of structures to memory, the physical memory layout of a class cannot be inferred by looking at the class declaration.

The Java class loader implements additional security procedures. When a class is loaded from across the network, it is put into a separate class partition based on its origin. This prevents a remote class from spoofing (pretending to be) a local class. Additional Java security mechanisms are provided by the bytecode verifier and by the interfaces contained in the Java networking package.

Multithreaded

Java is a multithreaded language. A Java program can start multiple threads of execution, each performing its own sequence of operations at the same time. The Java language provides all the tools for threads to acquire and release locks in a manner that minimizes deadlock conditions. Java also provides programming mechanisms to synchronize access to methods and develop functionality in a thread-safe manner.

Versatile and Expandable

One of the great advantages of Java is its versatility. The Java language covers a wide range of programming disciplines. You can perform network programming, develop GUIs, and create scientific and engineering applications using a single programming language. There is no more mixing and matching languages, no more Common Gateway Interface (CGI) scripts or language integration issues.

Another strength of Java is that it is expandable. New class libraries are constantly being made available for you to download and incorporate into your program development. Java provides all the framework and tools for you to develop your own class libraries too. New classes can easily be incorporated into the existing language framework.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net