Sams Teach Yourself C in 21 Days

(singke) #1
Object-Oriented Programming Languages 641

BD1


The Java Programming Language ......................................................................


You might not believe it, but the Java language was first conceived as a way to program a
device called Star7 (*7) that could control household appliances. The originators of Java,
a company called Sun Microsystems, were looking into the future to a time when a
house’s appliances—its video cassette recorder, furnace, stereo, refrigerator, and so on—
would all be connected to a network and controlled by a central computer. What charac-
teristics would such a language require? Here are the most important ones:


  • It should be architecture neutral. This is just a fancy way of saying that the opera-
    tion of the language does not depend on the hardware it is running on.

  • It should be robust. Programs written in Java need to be highly resistant to crashes.

  • It should be object oriented. The advantages of the object-oriented approach
    greatly reduce the chance of unforeseen errors. Plus, they can make fixing errors
    easier should they occur.

  • It needs to be safe. Being designed for networked computing, Java needs to be safe
    from possible attack by viruses.

  • It must combine power with simplicity. Java should not limit the programmer in
    any way, but also it must not be confusing and hard to learn.
    None of these individual features is new. What is new is the attempt to combine them all
    in a single programming language. It was soon realized that the power of this new lan-
    guage gave it many uses beyond the programming of appliances. Now, hundreds of thou-
    sands of developers have chosen Java as their language of choice.


The Relationship of Java to C and C++ ........................................................

When you start looking at Java code, a lot of it will be familiar. This is to be expected
because Java is based on the C++ language—and, as you learned earlier today, C++ is
based on C. However, there are significant differences between the Java:C++ relationship
and the C++:C relationship.
C++, you will recall, is a superset of C. This means that C++ includes all parts of C and
then adds on a bunch of new stuff (mainly the object-oriented features). Okay, that
sounds reasonable. Is Java then C++ with still more features added?
No. In fact, it is most accurate to think of Java as C++ with some features removed. This
might sound strange, but it really makes a lot of sense. C++ is an extremely powerful and
flexible language, and it lets you do just about anything you want in just about any way
you want. With that flexibility comes danger and complexity, which go against the
desired characteristics of Java. Thus, Java can be thought of as C++ without those fea-
tures that cause unnecessary complexity, jeopardize security, interfere with hardware
independence, and so on.

36 448201x-Bonus1 8/13/02 11:18 AM Page 641

Free download pdf