|
|
Sun describes Java as a "simple,
object-oriented, interpreted, robust, secure,
architecture-neutral, portable,
high-performance, multithreaded, and dynamic
language."
Each of the features mentioned
in this quotation from Sun's Web page is an
important part of the Java development
environment as well as a critical requirement
for Web programming. The combination of these
features makes Java a powerful and useful
programming language that empowers you, the
programmer, with the tools you need to easily
create powerful programs for today's distributed
environments.
Java is simple to use for
three main reasons: First, Java is familiar to
you if you know C. Second, Java eliminates
components of C that cause bugs and memory leaks
and replaces their functionality with more
efficient solutions and automated tasks, so you
have a lot less debugging to worry about than
you would using C or C++. Third, Java provides a
powerful set of pre-tested class libraries that
give you the ability to use their advanced
features with just a few additional lines of
code.
Java is an object-oriented
programming language that uses software objects
called classes and is based upon
reusable, extensible code. This means that you
can use Java's classes, which are sets of
variables and methods, as templates to create
other classes with added functionality without
rewriting the code from the parent classes or
superclasses. If you plan your application's
class hierarchy well, your application will be
small and easy to develop.
Java is robust because the
language removes the use of pointers and the
Java runtime system manages memory for you. The
problems with pointers in C and C++ was that
pointers directly addressed memory space. In a
distributed environment like the Internet, when
code is downloaded to diverse systems, there is
no way of knowing for sure that memory space
addressed by pointers is not occupied by the
system. Overwriting this memory space could
crash a system. Java also gives you automatic
bounds checking for arrays, so they cannot index
address space not allocated to the array.
Automatic memory management is done using the
Garbage Collector.
Java is interpreted, so your
development cycle is much faster. As you learn
later when the Java interpreter is discussed,
you need only to compile for a single, virtual
machine and your code can run on any hardware
platform that has the Java interpreter ported to
it.
Java is secure, so you can
download Java programs from anywhere with
confidence that they will not damage your
system. Java provides extensive compile-time
checking, followed by a second, multilayered
level of runtime checking.
Java is architecture neutral,
so your applications are portable across
multiple platforms. Java's applications are
written and compiled into bytecode for Java's
virtual machine, which emulates an actual
hardware chip. Bytecode is converted to binary
machine code by the Java interpreter installed
at the client, so applications need not be
written for individual platforms and then ported
from platform to platform. Java additionally
ensures that your applications are the same on
every platform by strictly defining the sizes of
its basic data types and the behavior of its
arithmetic operators. Operator overloading, the
process of modifying the behavior of operators,
is prohibited by Java.
Java is "high performance"
because its bytecode is efficient and has
multithreading built in for applications that
need to perform multiple concurrent activities.
Although threads still require the use of
classes, Java balances the addition of thread
synchronization between the language and class
levels. Java's bytecode is efficient because it
is compiled to an intermediate level that is
near enough to native machine code that
performance is not significantly sacrificed when
the Java bytecode is run by the interpreter.
Java is dynamic, so your
applications are adaptable to changing
environments because Java's architecture allows
you to dynamically load classes at runtime from
anywhere on the network, which means that you
can add functionality to existing applications
by simply linking in new classes. For example,
if your applet is being run by a browser that
doesn't have one of the classes included in your
applet's bytecode, the browser can download the
appropriate class from the server that is
storing your applet, check the bytecode, and
execute it. This is assuming your browser has
not been configured with strict security. |
|