Thursday, August 10, 2023

Objective-C Internals

Brian T. Kelley (via Dave Verwer):

Get ready to dive deep into the inner workings of the Objective-C language and runtime! Each post delves into a specific aspect of the language and explores the details of its implementation. I hope you’ll find this valuable to demystify the language, tackle tricky bugs, and optimize your code for performance.


Highly recommended! Even if you lived through all this evolution, and spend way too much time staring at hex dumps in the debugger, you’ll still learn something.

Update (2023-08-15): See also: Hacker News.

Update (2023-08-28): Scott Perry:

wrt immortal objects in Python, I can’t believe adding a conditional branch in the refcount code path didn’t cause measurable performance issues; we got a big win when we moved the tag bit to the top of object pointers so we could use p<=0 on the fast path to catch nil and tagged pointers in one shot.

1 Comment RSS · Twitter · Mastodon

I spent a couple of hours reading this last week. Amazing. I figured I probably knew most of this, but there was a LOT that I didn't know, especially since he covers all of the changes made over the last decade as Apple changed the ObjC runtime to support Swift and Apple Silicon. I've never seen any of that before.

Even if you're a Swift only programmer, you're still using the ObjC runtime under the hood every minute. I suppose you don't really *need* to know these internals, but they are absolutely fascinating. Glad to see this being shared far and wide.

Leave a Comment