← the guideObjects Ascendant

§ 02 — Eras · 1984

Objective-C

Smalltalk messages bolted onto C — Apple’s thirty-year accent

Left: era context, features, and the 101 hello. Right: 3 core concepts, 3 deeper 201 lessons, the factorial specimen, and where Objective-C lives today — each column scrolls on its own.

creators
Brad Cox & Tom Love, 1984
status
maintenance mode · runs macOS legacy and thousands of apps
lineage
← Smalltalk-80

The problem it solves

Objects were proven, but C owned systems software. Objective-C brought messaging to C with a layer thin enough to ship.

The problem it carries

Verbose brackets, two type systems in one file, and (for most of its life) memory management by hand.

Key features

the message
Bracket syntax for any message; the selector is a first-class string you can build at run time.
reference counting
Ownership by retain and release — manual before ARC, automatic after.
categories
Extend any class, including ones you did not write and cannot change.
a dynamic runtime
Message forwarding, runtime introspection and key-value observing underneath it all.

101 — hello, world

Session one is the smallest program that still counts as speaking Objective-C: what every tutorial prints first, in the dialect that mattered when the language arrived (1984).

the first program1984
#import <Foundation/Foundation.h>

int main(void) {
  NSLog(@"Hello, world");
  return 0;
}

101First contact — hello world and 3 ideas that define how Objective-C reads. 201 — 3 lessons on mechanisms you meet after the factorial specimen: the sharp edges practitioners actually use.

101 — core concepts

3 fragments, each naming a habit of mind in Objective-C. Read the note, then the code — together they are the 101 in one sitting.

01 — the bracket message

A message send in brackets: receiver, selector, arguments. Verbose, unmistakable.

NSString *s =
  [@"Mac" stringByAppendingString:@"intosh"];

02 — interface & implementation

The @-directives layer objects over plain C — two languages, one file.

@interface Ship : NSObject
@property (copy) NSString *name;
- (void)sail;
@end

03 — categories

Open any class and add methods — for better and for worse.

@interface NSString (Nautical)
- (BOOL)isShipName;
@end

201 — going deeper

The 201 assumes you have read the 101 and the specimen. Each lesson is one mechanism — what it is for, how it looks in code, and the trap or payoff that makes Objective-C distinctive at scale.

  1. blocks
  2. the runtime
  3. nullability and lightweight generics

blocks

Blocks are closures with captured state — the way to pass behaviour to asynchronous APIs without the ceremony of a target-selector pair.

[array enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *stop) {
  NSLog(@"%@", obj);
}];

the runtime

Objective-C’s runtime is an object graph you can edit at run time: swizzling a method, adding a class, or forwarding a message no one implements.

Method m = class_getInstanceMethod([Foo class],
                                     @selector(bar));
method_exchangeImplementations(m, other);

nullability and lightweight generics

Nullability annotations and parameterized types are compile-time only — they erase to plain objects, keeping the runtime compatible.

- (nullable NSArray<NSString *> *)namesFor:(nonnull NSString *)key;

The specimen — factorial

The bracket message: Smalltalk’s words bolted onto C’s bones — verbose, unmistakable, and the sound of Apple software for thirty years.

the bracket message1984
NSString *s =
  [@"Mac" stringByAppendingString: @"intosh"];

Run it today

runclang -framework Foundation fact.m -o fact && ./fact

Where it is now

Legacy Apple platforms; Swift interoperates with it to this day.