Since
ago

Ferreira's Home Page


Objective-C Bit #1: Hello, someone

Objective-C is a superset of C which supports object-oriented programming by adding to the C language message expressions. Together comes all the support for defining classes and other useful artifacts.

Objective-C has been inspired in Smalltalk-80 and seems a little odd for the ones accustomed to the standard C look-and-feel of the code. Despite the first impressions, programming in this language is simple, much simpler than C++.

@interface Hello {
  char* who;
}

- init: (char*)someone;
- greet;
@end

@implementation Hello

- init: (char*)someone {
	who = someone;
}

- greet {
	printf("Hello, %s! And hello, world!\n", who);
}

@end

int main(void) {
  id hello = [[Hello alloc] init];
  [hello greet];
}

KEYWORDS

Hello, world; Objective-C