Java Reference
In-Depth Information
Ask the Expert
Q :
To address the issues of portability and security, why was it necessary to create
a new computer language such as Java; couldn't a language like C++ be adap-
ted? In other words, couldn't a C++ compiler that outputs bytecode be created?
A : While it would be possible for a C++ compiler to generate something similar to byte-
code rather than executable code, C++ has features that discourage its use for the cre-
ation of Internet programs—the most important feature being C++'s support for
pointers. A pointer is the address of some object stored in memory. Using a pointer,
it would be possible to access resources outside the program itself, resulting in a se-
curity breach. Java does not support pointers, thus eliminating this problem.
Object-Oriented Programming
At the center of Java is object-oriented programming (OOP). The object-oriented method-
ology is inseparable from Java, and all Java programs are, to at least some extent, object-
oriented. Because of OOP's importance to Java, it is useful to understand in a general way
OOP's basic principles before you write even a simple Java program. Later in this topic,
you will see how to put these concepts into practice.
OOP is a powerful way to approach the job of programming. Programming methodolo-
gies have changed dramatically since the invention of the computer, primarily to accom-
modate the increasing complexity of programs. For example, when computers were first
invented, programming was done by toggling in the binary machine instructions using the
computer's front panel. As long as programs were just a few hundred instructions long,
this approach worked. As programs grew, assembly language was invented so that a pro-
grammer could deal with larger, increasingly complex programs, using symbolic represent-
ations of the machine instructions. As programs continued to grow, high-level languages
were introduced that gave the programmer more tools with which to handle complexity.
The first widespread language was, of course, FORTRAN. Although FORTRAN was a
very impressive first step, it is hardly a language that encourages clear, easy-to-understand
programs.
The 1960s gave birth to structured programming. This is the method encouraged by lan-
guages such as C and Pascal. The use of structured languages made it possible to write
moderately complex programs fairly easily. Structured languages are characterized by their
support for stand-alone subroutines, local variables, rich control constructs, and their lack
Search WWH ::




Custom Search