Simon Willison’s Weblog

Subscribe

8 items tagged “objectivec”

2024

Tagged Pointer Strings (2015) (via) Mike Ash digs into a fascinating implementation detail of macOS.

Tagged pointers provide a way to embed a literal value in a pointer reference. Objective-C pointers on macOS are 64 bit, providing plenty of space for representing entire values. If the least significant bit is 1 (the pointer is a 64 bit odd number) then the pointer is "tagged" and represents a value, not a memory reference.

Here's where things get really clever. Storing an integer value up to 60 bits is easy. But what about strings?

There's enough space for three UTF-16 characters, with 12 bits left over. But if the string fits ASCII we can store 7 characters.

Drop everything except a-z A-Z.0-9 and we need 6 bits per character, allowing 10 characters to fit in the pointer.

Apple take this a step further: if the string contains just eilotrm.apdnsIc ufkMShjTRxgC4013 ("b" is apparently uncommon enough to be ignored here) they can store 11 characters in that 60 bits!

# 8th May 2024, 2:23 pm / c, objectivec, strings

2009

10 Uses for Blocks in C/Objective-C. Part of the Cocoa for Scientists series, which is by far the best free Objective-C / Cocoa tutorial I’ve seen anywhere.

# 16th November 2009, 2:27 pm / blocks, closures, cocoa, objectivec, osx, science

Mac OS X 10.6 Snow Leopard: the Ars Technica review. The essential review: 23 pages of information-dense but readable goodness. Pretty much everything I know about Mac OS X internals I learnt from reading John Siracusa’s reviews—this one is particularly juice when it gets to Grand Central Dispatch and blocks (aka closures) in C and Objective-C.

# 1st September 2009, 7:05 pm / apple, blocks, c, closures, grandcentraldispatch, john-siracusa, objectivec, osx, snowleopard

Switching from scripting languages to Objective C and iPhone: useful libraries. Matt Biddulph collects together some very useful libraries for developers just getting started with Objective-C (though I’m not too keen on the title).

# 27th January 2009, 5:50 pm / iphone, matt-biddulph, objectivec, programming

2008

Blocks in Objective-C. Closures are coming soon to Objective-C - interesting syntax, a regular curly brace block preceded by a caret ^{ ... }.

# 29th December 2008, 7:38 pm / blocks, closures, objectivec, programming, syntax

An interview with 280 North on Objective-J and Cappuccino. Fantastic comment thread with involvement from the guys who created Objective-J. Just like Objective-C, Objective-J is a preprocessor that runs against regular JavaScript source files so you can use JavaScript and Objective-J idioms interchangeably.

# 7th June 2008, 7:40 pm / 280north, ajaxian, javascript, objectivec, objectivej

280slides and Objective-J. 280 slides uses an Objective-C clone written in 13KB of JavaScript. I have to admit I’m completely baffled as to why you would want to use Objective C instead of JavaScript, but evidently it worked fantastically well for them.

# 7th June 2008, 4:09 pm / 280slides, compiler, javascript, ned-batchelder, objectivec

2007

Programming Nu (via) Interesting new programming language—Lisp style syntax, Ruby style semantics, built in Objective C bridge so you can access Cocoa APIs directly.

# 1st October 2007, 9:49 pm / cocoa, lisp, nu, objectivec, programming, ruby