Archive for March 12, 2012

Monday, March 12, 2012

Recursive Mutexes Considered Harmful

David Butenhof (via Hacker News):

But nobody was supposed to use recursive mutexes. For the original intended purpose, only the global mutex would work anyway. And if you could analyze the code paths enough to know that a separate mutex was safe, why the heck would anyone want the overhead and complication of a recursive mutex instead of just doing it right?

Recursive locks were added to POSIX as a demonstration of attributes objects.

Update (2013-09-24): Brent Simmons:

David Butenhof explains, in 2005 in comp.programming.threads, why POSIX has recursive mutexes: “Because of a dare.” Inaccessible After July

Adam C. Engst:

There’s nothing wrong with Documents in the Cloud, as long as you see it as a virtual syncing cable and not as a collaborative work tool., weak as it was, at least tried to provide collaboration features in the form of Web-based manual file sharing, comments on shared iWork documents, and an ongoing chat-style discussion. Documents in the Cloud offers none of those features. had been in public beta for more than three years. It was pretty clear that Apple didn’t care about it and perhaps never knew what to do with it. Apple’s new model seems to be that a document is edited by one user in one app on multiple devices. It’s sort of pretending that workflows involving multiple apps or users editing the same document don’t exist.

It’s a shame that, as with the MobileMe Photo Gallery and Web hosting, Apple is setting an arbitrary deadline, not too far in the future, after which they will delete lots of user data that may not exist anywhere else. What if you’re away or don’t get the e-mail? And why make all the users migrate their data manually; why can’t Apple automatically transfer the documents to iCloud?

Quickly Sleeping Apple TV

Adam C. Engst:

One tip: press and hold the remote’s Menu button to jump quickly back to the main screen, where you can press and hold the center select button to put the Apple TV to sleep.

Objective-C Operators

Gwynne Raskind:

I do strongly support the concept of @== and @!= operators that equate to [object isEqual:] and its negation, as well as the associated @<, @> etc. operators. If one of the objects in question can be determined not to implement compare:, throw a compile error. If either operand is typed id, throw a runtime exception, exactly as [(id)[[NSObject alloc] init] compare:] would do now. In short, make the operators mere syntactic sugar, just like dot-syntax and the collection literals, rather than trying to toy with the runtime as @"" does.

The new collection literals and indexing syntax are no longer under NDA. The full details (e.g. the meaning of negative indexes) are still forthcoming, but it looks as though Apple got this right. Raskind’s proposal seems like a good next step.

Objective-C, Unversioned

Chris Lattner:

We’ve had internal discussions and have explicitly decided not to version the language any more. Instead of “Objective-C 2.0” or some such, there is now just “Objective-C as of Xcode 4.4” or “Objective-C in LLVM Compiler/Clang 4.0”.

If you’d like to reason about or conditionalize your code on various language features, please use the Clang feature checking macros.

It makes sense to check for features when writing code, but I think version numbers are useful for talking about, documenting, and referencing the language.


Lex Friedman:

Quick Look is a delightfully simple way to browse the contents of the files on your Mac without launching their parent apps. (Select a file, press the space bar, that’s it.) But if you’re looking at, say, a PDF or Word document, Quick Look can frustrate, because it doesn’t provide any way to select and copy text; if you find a snippet of text you’d like to copy and paste, you still need to launch the parent app.

I wonder why Apple never enabled this by default. Quick Look is a great idea, but it seems needlessly limited in what it allows users to do with the previews. Likewise, viewing applications using the Quick Look API can only access thumbnail images, not the full previews that generating applications make available to Quick Look.