<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: objective-c</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/objective-c.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2024-05-08T14:23:13+00:00</updated><author><name>Simon Willison</name></author><entry><title>Tagged Pointer Strings (2015)</title><link href="https://simonwillison.net/2024/May/8/tagged-pointer-strings-2015/#atom-tag" rel="alternate"/><published>2024-05-08T14:23:13+00:00</published><updated>2024-05-08T14:23:13+00:00</updated><id>https://simonwillison.net/2024/May/8/tagged-pointer-strings-2015/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://mikeash.com/pyblog/friday-qa-2015-07-31-tagged-pointer-strings.html"&gt;Tagged Pointer Strings (2015)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Mike Ash digs into a fascinating implementation detail of macOS.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Here's where things get really clever. Storing an integer value up to 60 bits is easy. But what about strings?&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Drop everything except &lt;code&gt;a-z A-Z.0-9&lt;/code&gt; and we need 6 bits per character, allowing 10 characters to fit in the pointer.&lt;/p&gt;
&lt;p&gt;Apple take this a step further: if the string contains just &lt;code&gt;eilotrm.apdnsIc ufkMShjTRxgC4013&lt;/code&gt; ("b" is apparently uncommon enough to be ignored here) they can store 11 characters in that 60 bits!

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/5417dx/storing_data_pointers#c_noslq0"&gt;Lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/c"&gt;c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/strings"&gt;strings&lt;/a&gt;&lt;/p&gt;



</summary><category term="c"/><category term="objective-c"/><category term="strings"/></entry><entry><title>10 Uses for Blocks in C/Objective-C</title><link href="https://simonwillison.net/2009/Nov/16/cocoa/#atom-tag" rel="alternate"/><published>2009-11-16T14:27:15+00:00</published><updated>2009-11-16T14:27:15+00:00</updated><id>https://simonwillison.net/2009/Nov/16/cocoa/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.macresearch.org/cocoa-scientists-xxxii-10-uses-blocks-cobjective-c"&gt;10 Uses for Blocks in C/Objective-C&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Part of the Cocoa for Scientists series, which is by far the best free Objective-C / Cocoa tutorial I’ve seen anywhere.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/blocks"&gt;blocks&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/closures"&gt;closures&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/cocoa"&gt;cocoa&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/macos"&gt;macos&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/science"&gt;science&lt;/a&gt;&lt;/p&gt;



</summary><category term="blocks"/><category term="closures"/><category term="cocoa"/><category term="macos"/><category term="objective-c"/><category term="science"/></entry><entry><title>Mac OS X 10.6 Snow Leopard: the Ars Technica review</title><link href="https://simonwillison.net/2009/Sep/1/siracusa/#atom-tag" rel="alternate"/><published>2009-09-01T19:05:25+00:00</published><updated>2009-09-01T19:05:25+00:00</updated><id>https://simonwillison.net/2009/Sep/1/siracusa/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars"&gt;Mac OS X 10.6 Snow Leopard: the Ars Technica review&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/apple"&gt;apple&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/blocks"&gt;blocks&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/c"&gt;c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/closures"&gt;closures&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/grandcentraldispatch"&gt;grandcentraldispatch&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/john-siracusa"&gt;john-siracusa&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/macos"&gt;macos&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/snowleopard"&gt;snowleopard&lt;/a&gt;&lt;/p&gt;



</summary><category term="apple"/><category term="blocks"/><category term="c"/><category term="closures"/><category term="grandcentraldispatch"/><category term="john-siracusa"/><category term="macos"/><category term="objective-c"/><category term="snowleopard"/></entry><entry><title>Switching from scripting languages to Objective C and iPhone: useful libraries</title><link href="https://simonwillison.net/2009/Jan/27/switching/#atom-tag" rel="alternate"/><published>2009-01-27T17:50:04+00:00</published><updated>2009-01-27T17:50:04+00:00</updated><id>https://simonwillison.net/2009/Jan/27/switching/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.hackdiary.com/2009/01/26/switching-from-scripting-languages-to-objective-c-and-iphone-useful-libraries/"&gt;Switching from scripting languages to Objective C and iPhone: useful libraries&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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).


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/iphone"&gt;iphone&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/matt-biddulph"&gt;matt-biddulph&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/programming"&gt;programming&lt;/a&gt;&lt;/p&gt;



</summary><category term="iphone"/><category term="matt-biddulph"/><category term="objective-c"/><category term="programming"/></entry><entry><title>Blocks in Objective-C</title><link href="https://simonwillison.net/2008/Dec/29/blocks/#atom-tag" rel="alternate"/><published>2008-12-29T19:38:08+00:00</published><updated>2008-12-29T19:38:08+00:00</updated><id>https://simonwillison.net/2008/Dec/29/blocks/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.mikeash.com/?page=pyblog/friday-qa-2008-12-26.html"&gt;Blocks in Objective-C&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Closures are coming soon to Objective-C - interesting syntax, a regular curly brace block preceded by a caret &lt;code&gt;^{ ... }&lt;/code&gt;.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/blocks"&gt;blocks&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/closures"&gt;closures&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/programming"&gt;programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/syntax"&gt;syntax&lt;/a&gt;&lt;/p&gt;



</summary><category term="blocks"/><category term="closures"/><category term="objective-c"/><category term="programming"/><category term="syntax"/></entry><entry><title>Cappuccino Web Framework</title><link href="https://simonwillison.net/2008/Sep/5/cappuccino/#atom-tag" rel="alternate"/><published>2008-09-05T15:27:54+00:00</published><updated>2008-09-05T15:27:54+00:00</updated><id>https://simonwillison.net/2008/Sep/5/cappuccino/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://cappuccino.org/"&gt;Cappuccino Web Framework&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Now open source (LGPL)—the Objective-C-in-JavaScript web application toolkit from 280 North, who are speaking at this year’s FOWA in October. Beautiful logo.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/cappuccino"&gt;cappuccino&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/lgpl"&gt;lgpl&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-j"&gt;objective-j&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/open-source"&gt;open-source&lt;/a&gt;&lt;/p&gt;



</summary><category term="cappuccino"/><category term="javascript"/><category term="lgpl"/><category term="objective-c"/><category term="objective-j"/><category term="open-source"/></entry><entry><title>An interview with 280 North on Objective-J and Cappuccino</title><link href="https://simonwillison.net/2008/Jun/7/ajaxian/#atom-tag" rel="alternate"/><published>2008-06-07T19:40:11+00:00</published><updated>2008-06-07T19:40:11+00:00</updated><id>https://simonwillison.net/2008/Jun/7/ajaxian/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://ajaxian.com/archives/an-interview-with-280-north-on-objective-j-and-cappuccino"&gt;An interview with 280 North on Objective-J and Cappuccino&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/280north"&gt;280north&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ajaxian"&gt;ajaxian&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-j"&gt;objective-j&lt;/a&gt;&lt;/p&gt;



</summary><category term="280north"/><category term="ajaxian"/><category term="javascript"/><category term="objective-c"/><category term="objective-j"/></entry><entry><title>280slides and Objective-J</title><link href="https://simonwillison.net/2008/Jun/7/ned/#atom-tag" rel="alternate"/><published>2008-06-07T16:09:37+00:00</published><updated>2008-06-07T16:09:37+00:00</updated><id>https://simonwillison.net/2008/Jun/7/ned/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://nedbatchelder.com/blog/200806/280slides.html"&gt;280slides and Objective-J&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/280slides"&gt;280slides&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/compiler"&gt;compiler&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ned-batchelder"&gt;ned-batchelder&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;&lt;/p&gt;



</summary><category term="280slides"/><category term="compiler"/><category term="javascript"/><category term="ned-batchelder"/><category term="objective-c"/></entry><entry><title>Programming Nu</title><link href="https://simonwillison.net/2007/Oct/1/programming/#atom-tag" rel="alternate"/><published>2007-10-01T21:49:06+00:00</published><updated>2007-10-01T21:49:06+00:00</updated><id>https://simonwillison.net/2007/Oct/1/programming/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://programming.nu/"&gt;Programming Nu&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Interesting new programming language—Lisp style syntax, Ruby style semantics, built in Objective C bridge so you can access Cocoa APIs directly.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://daringfireball.net/linked/2007/october#mon-01-nu"&gt;John Gruber&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/cocoa"&gt;cocoa&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/lisp"&gt;lisp&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/nu"&gt;nu&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/programming"&gt;programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ruby"&gt;ruby&lt;/a&gt;&lt;/p&gt;



</summary><category term="cocoa"/><category term="lisp"/><category term="nu"/><category term="objective-c"/><category term="programming"/><category term="ruby"/></entry><entry><title>Targets for 2004</title><link href="https://simonwillison.net/2004/Jan/1/targets2004/#atom-tag" rel="alternate"/><published>2004-01-01T22:55:03+00:00</published><updated>2004-01-01T22:55:03+00:00</updated><id>https://simonwillison.net/2004/Jan/1/targets2004/#atom-tag</id><summary type="html">
    &lt;p&gt;Looking back on 2003, one thing really stuck out for me: I didn't learn a new programming language. &lt;a href="http://www.pragmaticprogrammer.com/"&gt;The Pragmatic Programmers&lt;/a&gt; recommend learning at least one new language every year, and I've heard similar advice from other notable authorities; Ruby's Matz made a similar point in &lt;a href="http://www.artima.com/intv/craft.html" title="Matz on Craftsmanship"&gt;an article&lt;/a&gt; published just the other day.&lt;/p&gt;

&lt;p&gt;I learned a number of new skills and technologies in 2003, and improved on my existing knowledge in more ways than I can count. Unfortunately, everything was building on stuff I already had experience with: I didn't really learn anything completely new.&lt;/p&gt;

&lt;p&gt;2004 will be very different, mainly because I will finally have access to a Mac. Objective C and AppleScript are both on my list, and I'm looking forward to doing some serious messing around with &lt;acronym title="Graphical User Interface"&gt;GUI&lt;/acronym&gt;s as well.&lt;/p&gt;

&lt;p&gt;Other than that, my two main geeky goals for this year are to become more active in the open source world (hopefully contributing some useful code) and to do a lot more writing outside of my blog. On a personal note, I plan to see at least some of America outside of Kansas. I'm only here until October and I want to make the most of it.&lt;/p&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/objective-c"&gt;objective-c&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/applescript"&gt;applescript&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="objective-c"/><category term="applescript"/></entry></feed>