Introduced in 1995, Java is a relatively young programming language.
While high-level, fully-interpreted scripting languages such
as Tcl, Perl
or Shell scripts are portable and slow,
compiled languages like C/C++ perform well but are more difficult
to program. Java takes the best from both side:
the performance of Java's interpreted byte-codes is better than
the high-level scripting languages, but offers the simplicity
and portability of a high level language.
Standalone Java Program example |
To complile hello.java, just type
javac hello.java
in a console. To run the program,
type
java hello
|
---|
hello.java
|
|
Java is advertised as a "simple, object-oriented, interpreted,
robust, secure, architecture neutral, portable, dynamic,
high-performance, multithreaded, and dynamic language":
- simple: while designed to look like C/C++, it removes complexities
of C. Because a programmer should learn Java quickly,
the number of language constructs is small and kept
familiar to a majority of programmers to ease the migration.
- object-oriented: means focus on data rather than procedures. In Java,
hierarchically organized classes form a collection of data and methods.
Except of numeric, character, and boolean types, other types like
for example strings or threads are objects. A class is the basic unit of
compilation and of execution in Java; all Java programs are classes.
- interpreted: the Java compiler generates code for a Java Virtual Machine
rather than native machine code. To run a Java program, the Java
interpreter executes the compiled byte-code which is
platform-independent.
- architecture neutral:
The neutral byte-code format can run on any system
as long as that system implements the Java Virtual Machine.
This is ueful in heterogenous networks. It is also easier to develop applications
which run simultaneously on PCs, Mac, and UNIX workstations.
- portable:
While the architecture neutral, byte-code format makes it already portable,
Java knows no "implementation-dependent" aspects in the specification.
For example, Java explicitly specifies the size of each of the primitive data type
and their behavior.
- dynamic:
Any Java class can be loaded into a running Java interpreter
at any time. Native code libraries can also be dynamically
loaded. One can dynamically obtain information about a class at run-time.
- distributed:
A Java interpreter to download and
run code from across the Internet. Java implements strong
security measures, to make sure that the code can be run safely.
This is what happens when a Web browser downloads and
runs a Java applet, for example.
- robust:
Java is a strongly typed language, which allows for
extensive compile-time checking.
This is relevant for example in the area of function declarations.
Because the compiler catch more errors, this leads to more reliable programs.
- secure:
Java was designed with security in mind,
and provides several layers of security controls that
protect against malicious code, and allow users to
comfortably run untrusted programs such as applets.
- performance:
As an interpreted language, Java can not be
as fast as a compiled language like C.
Java 1.1 is 10 times slower than C. Many Java interpreters
however include "just in time" compilers that translate Java
byte-codes into machine code for a particular CPU at run-time.
- multithreaded:
Multithreaded means support for multiple threads of
execution which can handle different tasks.
Multithreading can for example improves the interactive
performance of graphical applications.
|
|
|