The following table shows some similarities and differences in features and the use of terms and concepts in Smalltalk, C++, and Java.
OO Concept/syntax  |       Smalltalk  |      C++  |      Java  |     |
Abstract class  |        Concept exists, no mechanism for enforcement  |       A class with a pure virtual function can't be instantiated  |      Classes may be declared abstract  |     |
Assignment operator  |       :=  |       =  |      =  |     |
Character constant  |       $c  |       'c'  |      'c'  |     |
Class  |         Class  |       Class  |      Class  |     |
Class method (corresponds to a message sent to the class rather than an instance)  |       Class method  |       Static function member  |      Class (or static) method  |     |
Class variable (data associated with the class, not an instance)  |       Class variable  |       Static data member  |      Class field  |     |
Comment  |       "Comment"  |       // Comment        |       // Comment        |      |
Dynamic binding  |       Unrestricted  |       Only subclasses of the declared class  |      Subclasses of the declared class or implementations of the declared interface  |     |
Equality test (see also identity test)  |       =  |       ==  |      equals()  |     |
Finalization of instances before deletion (e.g., to release operating system resources)  |       Some implementations support finalize method  |       Destructor function  |      finalize method is standard  |     |
Garbage collection (automatic memory management)  |       Garbage collection is standard  |       No garbage collection - programmer explicitly manages memory  |      Garbage collection is standard  |     |
Identity test (see also Equality test)  |       ==  |       same as equality  |      ==  |     |
Inheritance  |       Single inheritance only  |       Multiple inheritance  |      Single inheritance only  |     |
Initialization of instances  |       Override new method  |       Constructor function  |      Constructor function  |     |
Instance data or state  |       Instance variable  |       Data member  |      Instance field  |     |
Interface contract (specifies the public interface to classes that implement it)  |       No corresponding construct  |      No corresponding construct  |      Interface  |     |
Message  |       Message  |       Member function call  |      Method invocation  |     |
Message send syntax  |       anObject doIt  |       anObject.doIt() (direct)         |      anObject.doIt()  |     |
Method  |       Method  |       Member function  |      Method  |      |
Method argument syntax  |       methodName: argument (keyword method)  |       memberFunctionName(argument)  |      methodName(argument)  |     |
Method return  |       ^ (caret)  |       return  |      return  |     |
Object (root of all classes)  |      Class Object  |      No corresponding class  |      Class Object  |     |
Operator overloading (an aspect of polymorphism; different operator behavior based on receiver type)  |      Any operator can be overloaded  |      Any operator can be overloaded  |      Only methods can be overloaded, not built-in operators such as +, - , *  |     |
Pointers  |      No explicit storage pointers  |      Explicit use of storage pointers and pointer arithmetic  |      No explicit storage pointers  |     |
Self (the object executing a method)  |       self  |      this (usually not written)  |      this (usually not written)  |     |
String constant  |       'string constant'  |       "string constant"  |      "string constant"  |     |
Subclass  |       Subclass  |       Derived class  |      Subclass  |      |
Superclass  |       Superclass  |       Base class  |      Superclass  |      |
Superclass method invocation  |      super  |      :: (scoping operator, more general than Smalltalk or Java capability)  |      super()  |   | 
No comments:
Post a Comment