2024年6月15日发(作者:)

Java Technical Description

Java as a Programming Platform.

Java is certainly a good programming language. There is no doubt that it is one

of the better languages available to serious programmers. We think it could potentially

have been a great programming language, but it is probably too late for that. Once a

language is out in the field, the ugly reality of compatibility with existing code sets

in."

Java was never just a language. There are lots of programming languages out

there, and few of them make much of a splash. Java is a whole platform, with a huge

library, containing lots of reusable code, and an execution environment that provides

services such as security, portability across operating systems, and automatic garbage

collection.

As a programmer, you will want a language with a pleasant syntax and

comprehensible semantics (i.e., not C++). Java fits the bill, as do dozens of other fine

languages. Some languages give you portability, garbage collection, and the like, but

they don't have much of a library, forcing you to roll your own if you want fancy

graphics or networking or database access. Well, Java has everything—a good

language, a high-quality execution environment, and a vast library. That combination

is what makes Java an irresistible proposition to so many programmers.

Features of Java.

We wanted to build a system that could be programmed easily without a lot of

esoteric training and which leveraged today's standard practice. So even though we

found that C++ was unsuitable, we designed Java as closely to C++ as possible in

order to make the system more comprehensible. Java omits many rarely used, poorly

understood, confusing features of C++ that, in our experience, bring more grief than

benefit.

1

The syntax for Java is, indeed, a cleaned-up version of the syntax for C++. There

is no need for header files, pointer arithmetic (or even a pointer syntax), structures,

unions, operator overloading, virtual base classes, and so on. (See the C++ notes

interspersed throughout the text for more on the differences between Java and C++.)

The designers did not, however, attempt to fix all of the clumsy features of C++. For

example, the syntax of the switch statement is unchanged in Java. If you know C++,

you will find the transition to the Java syntax easy.

If you are used to a visual programming environment (such as Visual Basic), you

will not find Java simple. There is much strange syntax (though it does not take long

to get the hang of it). More important, you must do a lot more programming in Java.

The beauty of Visual Basic is that its visual design environment almost automatically

provides a lot of the infrastructure for an application. The equivalent functionality

must be programmed manually, usually with a fair bit of code, in Java. There are,

however, third-party development environments that provide "drag-and-drop"-style

program development.

Another aspect of being simple is being small. One of the goals of Java is to

enable the construction of software that can run stand-alone in small machines. The

size of the basic interpreter and class support is about 40K bytes; adding the basic

standard libraries and thread support (essentially a self-contained microkernel) adds

an additional 175K.

2. Object Oriented

Simply stated, object-oriented design is a technique for programming that

focuses on the data (= objects) and on the interfaces to that object. To make an

analogy with carpentry, an "object-oriented" carpenter would be mostly concerned

with the chair he was building, and secondarily with the tools used to make it; a

"non-object-oriented" carpenter would think primarily of his tools. The

object-oriented facilities of Java are essentially those of C++.

Object orientation has proven its worth in the last 30 years, and it is

inconceivable that a modern programming language would not use it. Indeed, the

object-oriented features of Java are comparable to those of C++. The major difference

2