Objective-J

Objective-J
Objective-J
Paradigm(s) Multi-paradigm: reflective, object oriented, functional, imperative, scripting
Appeared in 2008
Developer 280 North, Inc.
Typing discipline dynamic, weak, duck
Influenced by Objective-C, JavaScript
License LGPL
Website cappuccino.org

Objective-J is a programming language developed as part of the Cappuccino web development framework. Its syntax is nearly identical to the Objective-C syntax and it shares with JavaScript the same relationship that Objective-C has with the C programming language: that of being a strict, but small, superset; adding traditional inheritance and Smalltalk/Objective-C style dynamic dispatch. Pure JavaScript, being a prototype-based language, already has a notion of object orientation and inheritance, but Objective-J adds the use of class-based programming to JavaScript.

Programs written in Objective-J need to be preprocessed before being run by a web browser's JavaScript virtual machine. This step can occur in the web browser at runtime or by a compiler which translates Objective-J programs into pure JavaScript code. The Objective-J compiler is written in JavaScript; consequently, deploying Objective-J programs does not require a web browser plug-in.

Contents

Applications

The first widely known use of Objective-J was in the Cappuccino-based web application 280 Slides, which was developed by 280 North itself. Even though Objective-J can be used (and has been designed) independently from the Cappuccino framework, Objective-J has primarily been invented to support web development in Cappuccino.

Applications designed using the Cappuccino Framework[1]

Syntax

Objective-J is a superset of JavaScript, which means that any valid JavaScript code is also valid Objective-J code.

The following example shows the definition and implementation in Objective-J of a class named Address; this class extends the root object CPObject, which plays a role similar to the Objective-C's NSObject. This example differs from traditional Objective-C in that the root object reflects the underlying Cappuccino framework as opposed to Cocoa, Objective-J does not use pointers and, as such, type definitions do not contain asterisk characters (in Objective-C, all objects must be dynamically allocated). In addition, instance variable definitions are never done in the @implementation file.

@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 with Objective-C, class method definitions and instance method definitions start with '+' (plus) and '-' (dash), respectively.

Memory management

Like Objective-C 2.0's garbage-collected mode, objects in Objective-J do not need to be manually released because they are automatically freed by JavaScript's garbage collector.

See also

References

  1. ^ "Demos in Cappuccino". Demos in Cappuccino. http://cappuccino.org/learn/demos/. Retrieved 26 February 2011. 

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Objective-C — Paradigm(s) reflective, object oriented Appeared in 1983 Designed by Tom Love Brad Cox Developer Apple Inc. Typing discipline …   Wikipedia

  • Objective-C — Entwickler: Brad Cox, Tom Love Typisierung: stark, statisch, explizit Einflüsse: Smalltalk, C (Programmiersprache) Betriebssystem: Mac OS X …   Deutsch Wikipedia

  • Objective-C++ — Objective C, auch kurz ObjC genannt, erweitert die Programmiersprache C um Sprachmittel zur objektorientierten Programmierung. Objective C++ erlaubt teilweise die Mischung von Objective C mit C++ Code mit dem Ziel, älteren Code verwenden zu… …   Deutsch Wikipedia

  • Objective-c — Objective C, auch kurz ObjC genannt, erweitert die Programmiersprache C um Sprachmittel zur objektorientierten Programmierung. Objective C++ erlaubt teilweise die Mischung von Objective C mit C++ Code mit dem Ziel, älteren Code verwenden zu… …   Deutsch Wikipedia

  • Objective C — Objective C, auch kurz ObjC genannt, erweitert die Programmiersprache C um Sprachmittel zur objektorientierten Programmierung. Objective C++ erlaubt teilweise die Mischung von Objective C mit C++ Code mit dem Ziel, älteren Code verwenden zu… …   Deutsch Wikipedia

  • Objective C++ — Objective C, auch kurz ObjC genannt, erweitert die Programmiersprache C um Sprachmittel zur objektorientierten Programmierung. Objective C++ erlaubt teilweise die Mischung von Objective C mit C++ Code mit dem Ziel, älteren Code verwenden zu… …   Deutsch Wikipedia

  • Objective-C — Класс языка: объектно ориентированный, мультипарадигмальный: рефлексивно ориентированный Появился в: 1986 Автор(ы): Бред Кокс Типизация данных: нестрогая, статическая / динамическая …   Википедия

  • Objective-C — Información general Paradigma orientado a objetos Apareció en 1980 Diseñado por Brad Cox Tipo de dato …   Wikipedia Español

  • Objective-C — Apparu en 1983 Auteur Brad Cox et Tom Love Paradigme orienté objet, réflexif …   Wikipédia en Français

  • Objective-J — Класс языка: мультипарадигмальный: рефлексивно ориентированное, объектно ориентированное, функциональное, императивное, скриптовое Появился в: 2008 Типизация данных: динамическая, слабая, утиная …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”