Objective-C was designed to unify two domains: the static simplicity of C; with the flexibility of Smalltalk message passing. I’m not actually simplifying it that much by telling you that Objective-C is C, with two additions:
1. A small layer of syntax like square braces, interfaces, and selectors.
2. Your code runs alongside the Objective-C Runtime™.
This runtime powers all the characteristic capabilities associated with the language such as dynamism and object-oriented…ness.
In fact, Objective-C defers as much as possible away from compile-time and towards runtime. This was one of the core reasons it was chosen to run on the Motorola 68k chips of the NeXT workstations, because it gave blazingly fast compilation times compared to the era’s typical glacially slow compilers.
Swift is often called a protocol-oriented language. Devs often characterise Objective-C as a runtime-oriented language.
Everyday programming languages compile functions down to machine code and wire them up in a binary. Each function call knows, more or less, the memory offset to jump to for the executable implementation. All this information is known at compile-time.
Objective-C, on the other hand... improvises.
Methods are dispatched via message passing, where the runtime traverses a class hierarchy (or cache) to look up the implementations on-the-fly.
The runtime is where all the magic happens.
Read the full piece: “Ancient Secrets of the Objective-C Runtime” - here 📜
blog.jacobstechtavern.com/p/…