Relation of sC++ to Java

Active object creation

The main features that distinguishes JAVA from C++ are the possibility of declaring active objects, the simplification of the pointers and the use of an interpreted code.

sC++ has active objects that are very similar to JAVA's, but a simpler communication mechanism. This mechanism is prone to modelling and thus to analysis by the theories and tools that have been developed by logicians (CCS, temporal logic, Buchi automaton...).

sC++ is not interpreted and retains the same pointers as C++. It can directly call the libraries developed for C++.

sC++ active objects are created in the following way:

active class A {
public:
     void m () { ...... }
     A ()  { ........ }          //  constructor
private:
     @A () { ... accept m; ...}  //  body (runs in parallel with the  
};                               //        bodies of the other objects)
A aa, bb[4];

The line above automatically creates 5 active objects that run concurrently. It is not possible to create passive objects from a class that has been declared active.

Inter-object synchronization

In sC++, each method that is declared public in an active object is automatically synchronizing. There is no synchronised keyword. (In order to call a method without synchronization, one can use the keyword friend). The method call is thus the means used to communicate between active objects. It has exactly the same syntax as the usual call.

Only one method can be executing within an object at any one time, and only when the body is inactive (suspended or terminated).

The suspension of the body is made by the statement accept m; which works like the accept statement of Ada. The method m is executed when both the caller and the body are suspended on the call, respectively the accept statement:

B::@B () { 
       ......	
     accept m; 
       ......	
}	
                
                              
  <------------

   rendezvous
C::@C () {
      ......	
     bb->m(); 
      ......	
}	

Select statement

An object can enable several rendezvous simultaneously with the select statement. Calls, as well as accept statements can be written in a select statement.

D::@D () { 
    ... 
   select {
      accept m; 
       ...
   ||
      obj->meth();
       ...
   ||
      waituntil(T);
       ...
   }
    ...
}; 

Any number of calls, accept and delays can be written in a select statement. The first event that meets its complement is fired and the other ones are forgotten. After the method execution, the code that lies under the triggered event is executed and the select is exited.

Advantages over JAVA

In Java, a method can only be suspended inside the object. The caller is thus blocked if the awaited event is not readily available. In sC++, on the contrary, the caller is blocked just before it enters the methods. It can thus handle the other events of the select if they occur beforehand.

The identity of the method that is accepted is defined by the accepting object, which avoids rescheduling all methods, and providing them with the knowledge of what is expected for the termination of the method.

The semantic of sC++ corresponds exactly to CCS, the calculus of communicating systems, which allows all kinds of modelling, verifications, tests and specifications (See sC++ documentation).

sC++ provides an alternative to the widely used concept designated with the names of callback, inversion control or event driven programming, and allows a much more structured programming style. Around sC++, we have created development and debugging tools, and libraries such as CORBA that makes it very easy and quick to build interactive or distributed applications

Many examples have shown us that the concept used by sC++ makes the design, specification, and implementation of programs very easy.

Note that the active objects of JAVA could be easily completed with the interprocess communications means described herewith.