Canalblog
Editer l'article Suivre ce blog Administration + Créer mon blog
Publicité
welcome to googlefans
8 février 2006

Java is small

One of the features of Java which Sun neglected to mention in its definition was Java's size-or lack of it. As a side effect of being simple, Java is a very small. Remember that one of the original goals of Java was to facilitate the construction of software that ran stand-alone in small machines. The original *7 module that Java was developed for only had 3Mb of main memory. Java can happily run on personal computers with at least 4Mb of RAM or even VCRs, telephones, or doorknobs.

The size of the basic interpreter and class support is about 40K of RAM; adding the basic standard libraries and thread support (essentially a self-contained microkernel) adds an additional 175K. The combined total of approximately 215K is significantly smaller than comparable programming languages and environments.

Java is simple, (small), object-oriented...

Java is an object-oriented language. That means that it's part of a family of languages that focuses on defining data as objects and the methods that may be applied to those objects. As we've said, Java and C++ share many of the same underlying principles, they just differ in style and structure. Simply put, object-oriented (OO, for short) languages describe interactions among data objects. To make an analogy with medicine, an "object-oriented" doctor would be interested in holistic medicine - examining the body (or object) as a whole first, and the vaccines, diets, and medicine (the tools) used to make your health improve after that. A "non-object-oriented" doctor would think primarily of his tools.

Many OO languages support multiple inheritance, which can sometimes lead to confusion or unnecessary complications. Java doesn't; as part of its "less-is-more" philosophy, Java only supports single inheritance. That means that each class can only inherit from one other class at any given time. This avoids the problem of a class inheriting classes whose behaviors are contradictory or mutually exclusive.

Having said that, we should point out that, while Java does not support multiple inheritance per se, it does support abstract classes which can implement multiple inheritances. Abstract classes allow programmers to define methods for interfaces and worry about how the methods will be implemented later. This bypasses a lot of the problems inherent in actual multiple inheritance while still retaining most of the advantages.

Each class, whether abstract or not, defines the behavior of an object through a set of methods. All the code used for Java is divided into classes. Behaviors can be inherited from one class to the next, and at the head of the class hierarchy is the class called "Object". This is illustrated in figure 1.1, which shows a class called "meat" that inherits from class "Food", which, as all classes ultimately do, inherits from the class called OBJECT.

Objects can also implement any number of interfaces (or abstract classes, remember?). The Java interfaces are a lot like the Interface Definition Language interfaces. That similarity means that it's easy to build a compiler from IDL to Java.

That compiler could be used in the CORBA (Common Object Request Broker Architecture) system of objects to build distributed object systems. Is this good? Yes. Both IDL interfaces and the CORBA system are used in a wide variety of computer systems and this facilitates Java's platform independence, which we'll talk more about later.

As part of the effort to keep Java simple, not everything in this object-oriented language is an object. Booleans, numbers, and other simple types are not objects, but Java does have wrapper objects for all simple types. wow goldWrapper objects allow all simple types to be implemented as though they were classes.

Object-oriented design is also the mechanism which allows modules to "plug and play." The object-oriented facilities of Java are essentially those of C++, with extensions from Objective C for more dynamic method resolution.

Publicité
Publicité
Commentaires
welcome to googlefans
Publicité
Publicité