Concepts of Programming Languages

(Sean Pound) #1

92 Chapter 2 Evolution of the Major Programming Languages


After considering C and C++, it was decided that neither would be sat-
isfactory for developing software for consumer electronic devices. Although
C was relatively small, it did not provide support for object-oriented pro-
gramming, which they deemed a necessity. C++ supported object-oriented
programming, but it was judged to be too large and complex, in part because
it also supported procedure-oriented programming. It was also believed that
neither C nor C++ provided the necessary level of reliability. So, a new lan-
guage, later named Java, was designed. Its design was guided by the fun-
damental goal of providing greater simplicity and reliability than C++ was
believed to provide.
Although the initial impetus for Java was consumer electronics, none of the
products with which it was used in its early years were ever marketed. Starting
in 1993, when the World Wide Web became widely used, and largely because
of the new graphical browsers, Java was found to be a useful tool for Web pro-
gramming. In particular, Java applets, which are relatively small Java programs
that are interpreted in Web browsers and whose output can be included in
displayed Web documents, quickly became very popular in the middle to late
1990s. In the first few years of Java popularity, the Web was its most common
application.
The Java design team was headed by James Gosling, who had previously
designed the UNIX emacs editor and the NeWS windowing system.

2.17.2 Language Overview


As we stated previously, Java is based on C++ but it was specifically designed
to be smaller, simpler, and more reliable. Like C++, Java has both classes and
primitive types. Java arrays are instances of a predefined class, whereas in C++
they are not, although many C++ users build wrapper classes for arrays to add
features like index range checking, which is implicit in Java.
Java does not have pointers, but its reference types provide some of the
capabilities of pointers. These references are used to point to class instances.
All objects are allocated on the heap. References are always implicitly deref-
erenced, when necessary. So they behave more like ordinary scalar variables.
Java has a primitive Boolean type named boolean, used mainly for the
control expressions of its control statements (such as if and while). Unlike C
and C++, arithmetic expressions cannot be used for control expressions.
One significant difference between Java and many of its predecessors that
support object-oriented programming, including C++, is that it is not possible
to write stand-alone subprograms in Java. All Java subprograms are methods
and are defined in classes. Furthermore, methods can be called through a class
or object only. One consequence of this is that while C++ supports both pro-
cedural and object-oriented programming, Java supports object-oriented pro-
gramming only.
Another important difference between C++ and Java is that C++ supports
multiple inheritance directly in its class definitions. Java supports only single
Free download pdf