Saturday, May 09, 2009

Blocks in Cocoa ... finally

Apple's Objective-C Implementation and the Cocoa class library is once again getting more similar to Smalltalk. After Panther and Tiger introduced a usable MVC-like framework (Cocoa Bindings) Leopard added garbage collection.

And now it seems that Snow Leopard is getting Blocks as well:

So it Apple decides to wrap Number and Point as full classes (or do an auto-boxing/un-boxing) IMHO the only remaining difference is the runtime system. In Smalltalk the whole class/method structure is inspectable and changeable during runtime. In ObjC you can query/add classes/methods during runtime. Only removing classes/methods is impossible .... but maybe this will change in Snow Leopard as well.

1 comment:

Richard Kulisz said...

Auto-boxing and unboxing is interesting. At first I dismissed it because it's not the real thing. But everyone is so insistent that it's just as good that I started thinking about it. And you know, after a while it looked exactly as good. It took me a really long time to figure out in what ways they differ.

The difference is that if you do it for real, if you sink the abstraction to a lower level of implementation, if you don't auto-convert at the higher level ... then the abstraction can never, ever, ever be broken. When you rely on auto-conversion, some malicious bastard is going to find a way to break it. Always.

I couldn't afford that breach in security when implementing a capability security system so I'm back full circle to dismissing boxing/unboxing by saying "it's not the real thing". Though this judgement probably doesn't apply to numbers in objective-c since if it's anything like Smalltalk, it's got all the security of DOS. There's no point to worrying about security or malice in a fundamentally insecure single-user system.