Objective-J

Objective-J is a programming language developed at the same time as the Cappuccino framework . Its syntax is substantially identical to that of Objective-C . Furthermore it shares Javascript the same relationship that exists between the Objective-C language and C : it is a kind of set on adding the notion of inheritance and dynamic typing style Smalltalk / Objective-C to JavaScript.

Programs written in Objective-J need to be compiled before they can be launched in a web browser . This compilation can be performed directly in the browser at runtime by a compiler that compiles the Objective-J programs into pure Javascript code. The Objective-J compiler is written in JavaScript, so the program deployment written in Objective-J does not require a plugin attached to the browser.

Application

The first known use of Objective-J was made with the Cappuccino framework for the development of the 280Slides web application . Although Objective-J can be used (and was designed) independently of the Cappuccino framework, Objective-J was, basically, invented to support web development with Cappuccino.

Syntax

Objective-J is a superset of Javascript, implying that any valid JavaScript code is also valid in Objective-J code. The following example shows the Objective-J declaration of a class named Address , this class is a subclass of the base object CPObject that plays the same role as the NSObject in Objective-C / Cocoa. Even if it is not the same name for the base object, this code could also be an example for a class declaration in Objective-C.

@implementation Address: CPObject
{
 CPString name;
 CPString city;
}
- (id) initWithName: (CPString) aName city: (CPString) aCity
{
 Self = [super init];
 Name = aName;
 City = aCity;
 Return self;
}
- (void) setName: (CPString) aName
{
 Name = aName;
}
- (CPString) name
{
 Return name;
}
+ (Id) newAddressWithName: (CPString) aName city: (CPString) aCity
{
 Return [[self alloc] initWithName: aname city: aCity];
}
@end

As in Objective-C, the declaration of class methods and instances methods begin with ‘+’ (plus) and ‘-‘ (less) respectively.

Memory Management

Unlike Objective-C, objects in Objective-J do not need to be released since they are automatically released by the garbage collector in English : Garbage Collector of JavaScript.