Description #
Objective-C is a compiled, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. It was the primary language used for macOS and iOS development before the introduction of Swift.
History #
Objective-C was created in the early 1980s by Brad Cox and Tom Love at Stepstone as an extension of the C language with object-oriented capabilities. It became widely known when NeXT (founded by Steve Jobs) adopted it for its operating system. Apple later acquired NeXT, bringing Objective-C to macOS and iOS. It remained the dominant Apple development language until Swift was introduced in 2014.
Hello World Code #
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Hello, World!");
}
return 0;
}
How to Run #
Option 1: Online
Option 2: Local (macOS)
Open Terminal
Save code as hello.m
Compile and run:
clang -framework Foundation hello.m -o hello
./hello
Key Concepts #
- Based on C with object-oriented extensions
- Uses message-passing syntax (
[object message]
) - Dynamic runtime like Smalltalk
- Foundation and Cocoa frameworks
- Automatic Reference Counting (ARC)
- Categories and protocols
- Header (
.h
) and implementation (.m
) files - Interoperable with Swift and C
- Still supported by Apple in Xcode
- Known for verbose but flexible syntax
Try It Online #
Fun Facts #
- Apple’s early apps, including iTunes and Safari, were built using Objective-C.
- Steve Jobs helped popularize Objective-C via NeXT, which later became the foundation for macOS and iOS.
- Swift was designed to interoperate seamlessly with Objective-C.