waffle

Chemical Programming

Watch Bonnie Bassler speak about bacteria. Do it. It’s so good that she gets a well deserved standing ovation at the end.

If you’re doing any amount of programming more complex than “just” business logic, you’ll find many parallels to programming. She’s right that since bacteria have developed for several tens of thousands times longer than humans, the way they work is pretty resilient, interesting and applicable. It certainly appears to scale, if you’re into that sort of thing.

Augmented Literacy

Just a note for anyone as addicted to the terrific Dictionary popup (Command+Control+D) as I am; here’s how to make it work in Snow Leopard:

  • Open Service Preferences (System Preferences → Keyboard → Keyboard Shortcuts and choose Services in the list on the left), enable Look Up in Dictionary (under Searching) if it’s not already enabled, and set its shortcut to Command+Control+D by double-clicking at the right edge of its row.
  • Open Dictionary and its Preferences and select that the Contextual menu “Opens Dictionary panel”.

Of all the things to not migrate seamlessly…

Hidden Developer Gems in Snow Leopard

  • clang’s Static Analysis is built into Xcode. Build → Build and Analyze, and wonder how you ever accepted that scan-build web interface.
  • Concurrent NSView drawing, opt-in.
  • NSCache provides a data structure tuned for caching, where you associate an item with a cost and items can be silently evicted to maintain a small footprint, or because objects implementing the NSDiscardableContent protocol has proclaimed that the content isn’t actually useful anymore.
  • An alias class, finally. NSURLs are now bifurcated; one half contains an actual URL, and the other can contain alias evidence (under the guise of “bookmark data”) that can help track the file down after it’s been moved. The goal is to completely replace both string paths and FSRef aliases, and as far as I can see, all API has been updated to the point where an NSURL can be used.
  • Sudden termination, where you can flag your app as being constructed in such a way that, aside from specially delineated regions, the process can be instantly killed at any time.
  • NSImage has seen some much needed spring cleaning, including the deprecation of a slew of drawing methods. They’ve gotten closer to CGImageRefs and can be easily snapshotted into one, which may be the reason that CALayers can now take one as their contents.
  • You can enumerate collections concurrently using blocks.
  • Data detectors, as-you-type text replacement and a unified NSTextCheckingResult (text analysis like grammar and spell checking) model are news in NSTextView.
  • NSBrowser is a lot less insane, likely due to Finder’s Cocoa port.
  • Preparations are in place for bi-directional UI.
  • NSTextFields (and cells) can explicitly be set to “single line mode” which ignores any line or paragraph break and fixes the baseline.
  • Core Animation gains a slew of useful layers, including CAEmitterLayer for particle effects, CAShapeLayer for Bézier paths and CAGradientLayer for those of us who wondered why contents didn’t take NSGradients nor CGGradientRefs. You can also animate your layer subclass’s own properties.
  • NSString’s -localizedStandardCompare: provides Finder-like sorting.

ThisService and Snow Leopard

Since it’s now abundantly clear that Services will be much better in Snow Leopard, and since the guy who asked me to write ThisService in the first place has basically taken the stance that the new version of Automator that will allow for direct Service creation is good enough, I think I need to clarify exactly what will happen.

Here’s where ThisService stands today: ThisService 2.1, with a fixed crasher and some pipeline improvements, sits unreleased on my SSD, waiting for me to finish up its help book and polish the edges. There’s a plan for a future version — whether that’ll be 2.1 or not, I don’t currently know — that will let you set the service as accepting a specific type of input. (The new services system can use data detectors and these context hints to emphasize services that work with dates, addresses, URLs, phone numbers and email addresses.) Once this feature gets in, some people will ask for a way to change this information on existing ThisService services, and I will need to work out whether I’ll want to update the few hosted services with this information.

I’m not entirely sure about anything else beyond that. Services have always supported media beyond just text, and the new Automator unlocks the potential in being able to move files, folders, images, video and audio around. Changing ThisService simply to support creating such services is trivial. The reason I’ve chosen not to for so long is because the kinds of scripts people write using the methods ThisService support is not a natural fit for processing most of these things (besides perhaps files and shell scripts).

What if you make a Ruby script with ImageScience or MojoMagick to do image processing, and it turns out that running it strips embedded metadata? Just returning a pile of rearranged pixels isn’t good enough. ThisService had to come to terms with this problem on the text-only level already by deciding on a manifest text encoding (UTF-8); these other things bring much harder questions.

ThisService will be around for at least the shorter term because the new Automator isn’t a good IDE for creating scripting language services unless that scripting language is AppleScript, and there’s still a need for that. (Also, not everyone will run Snow Leopard in two weeks time.)

So, to recap. Snow Leopard, the new Services architecture and the new Automator are all good and advance the state of Services far more than any single change since their inception in NeXTStep over 20 years ago. These features finally put in place an official way provided by Apple to create Services without necessarily learning about Cocoa, and this is good for Services. There’s still a place for ThisService, and I intend to fill the gaps over time to make sure that it’s the best ThisService it can be. But I couldn’t tell you where exactly ThisService will go beyond those plans. I’m listening.

Older posts »