Oct 2003

At the OS X conference Scott Anguish did a 90-minute presentation on the new NSController layer in Cocoa.

Here’s a quick summary of what this is about:

Many applications have three different areas of code. One handles the data—that’s called the Model layer. Another handles display—that’s the View layer. A third goes between the first two—the Controller layer.

Cocoa gives you a ton of stuff that for the first two, the Model and View layers. The hard and often tedious part has traditionally between the Controller layer.

A simple example

Imagine a checkbox in a Preferences window. When you check it or un-check it, the preferences for your application updates.

What happens is this: the user checks the box (View layer), then a message is sent to the Controller layer that a checkbox has been checked. The message tells what checkbox was checked and the method can find out whether it was turned on or off. Then that method tells the Model layer to update the on/off flag for a given preference, and it gets saved to disk in the prefs file for that app.

In Cocoa, before NSController, you had to write that method I talked about above. It’s easy but tedious. And if you think about all the different user interface pieces of even a simple app, you see that there’s a bunch of this go-between code to write.

So the idea of NSController is to do a bunch of it for you.

In this simple example, what you do is say that the checkbox is bound to a given key in the prefs. When the checkbox is checked, the new NSController layer updates the prefs. In many cases no code at all is needed.

Complex stuff is handled too

Of course, there’s more to it than just that. NSController can do a ton more than just connecting checkboxes with your preferences and eliminating a little code. It can eliminate a lot of code and handle more complex things like table views and knowing when to enable and disable things and so on.

Drawbacks

For all that coolness, there are still drawbacks—for one thing it requires Panther. That’s not a criticism, because new features come with new operating systems: that’s just the way it goes.

But if you need to support 10.2 (or earlier) in your app then you’ll have to do without NSController.

There have been criticisms of NSController: most notably, Aaron Hillegass criticized NSController in an email to the Cocoa-Dev mailing list. I’m not going to summarize Aaron’s email; instead I’ll say that any developer should think about the points Aaron makes.

Bonus tip

The documentation that comes with the developer tools CD is not as up-to-date as what’s on Apple’s website. So use the on-line docs.

I caught Bill Bumgarner’s presentation on PyObjc at the OS X conference. I was surprised by how complete PyObjc is: according to Bill, it pretty much just works.

You can of course send messages back and forth across the PyObjc bridge: you can call Objective-C from Python and vice versa. You can even subclass Objective-C classes in Python. Things like Web Kit and the new NSController layer work with Python. And with Python you don’t have to deal with memory issues (retain/release/autorelease).

So, while all that’s very cool, I’m not about to switch away from Objective-C. But I can imagine using Python for a few things:

1. XML-RPC and other web services. Python is utterly remarkable as a web services language. I’ve used no other language as nice as Python for this stuff.

2. As a user scripting language. NetNewsWire for instance has a Scripts menu to which you can add AppleScript scripts. It would be cool if you could also put Python scripts in there that have at least the same level of access to NetNewsWire as the AppleScript scripts have. (Actually, it would be easy to give an even bigger level of access.)

3. Writing unit tests. Writing tests should be as frictionless as possible; Python would be a big help here.

I should point out that NetNewsWire already does use Python for one feature, though it’s not using PyObjc: the HTML differences code is a Python script by Aaron Swartz. (NetNewsWire just calls the script on disk via NSTask.)

Last night at the Innovators presentation at the O’Reilly OS X conference, Rael Dornfest brought up the old days of Mac shareware. (I immediately thought of Anarchie and MacHTTP; there are other great examples.)

The question got me wondering about the meaning of the word shareware.

I’m not sure what it means these days. My company may be small (my wife, me, and a fierce gray tabby), and we don’t have a physical box for our product, but I don’t think of our business as being fundamentally different from larger software companies. I’ve never called NetNewsWire a shareware app (though other people have, and it doesn’t bother me.)

What’s common to all three is that they develop and sell software. Some companies have boxes and large advertising budgets, sure, but I don’t think that’s the difference between shareware and commercial software.

You might say that there’s a difference of culture. Many small developers have weblogs, they’re open and accessible, outspoken but also good at listening. (Being good at listening is perhaps the key attribute of a successful small developer.) They are, in short, not corporate.

But the definition of shareware has traditionally had to do with how the software was distributed and not the attributes of the developer. What I think has happened is that the Internet has made even large companies shareware developers. Not long ago I downloaded Adobe Photoshop Elements, evaluated it during a demo period, then bought the software. I did the same thing with Transmit by Panic, which is a far smaller company. The experience was the same.

Is Transmit shareware? Is Photoshop Elements shareware?

Software

I prefer to think that Transmit and Photoshop Elements are, purely and simply, software. Software these days is often distributed online and has an evaluation period built in. Try before you buy. In that sense, I think the shareware model caught on all over the place, so much so that it’s now hard to talk about shareware as being different from the normal practices of software companies.

But... there clearly is something different about small developers. Something to do with weblogs and chat and talking and listening and sharing code and ideas. A community thing.

I just don’t know what to call it. Shareware community isn’t quite right (but I don’t really mind it, either). I’m not sure it needs a name, but maybe a name would be helpful? I don’t know.

I did clean installs of Panther, so I got the defaults of everything, and I discovered that the default shell in Panther is bash!

Given the popularity of bash on Linux that’s probably the right choice. But I’ve been using tcsh since the OS X public beta, and I don’t want to switch.

So, easily enough, I changed my shell to tcsh. In case you’re wondering how to do this, here’s what I did: in NetInfo Manager I navigated to /users/brent, then clicked the lock to make changes, then set the value of the shell property to /bin/tcsh, then I logged out then back in.

P.S. NetNewsWire tip: you can actually drag the RSS links above into your Subscriptions pane to subscribe. This works with any link to an RSS feed, and it often works with links to the home page of a site.

When you’re upgrading to a new version of OS X, and you want to make sure NetNewsWire doesn’t lose its subscriptions and preferences, you need to copy two things to your new installation:

1. The preferences file at ~/Library/Preferences/com.ranchero.NetNewsWire.plist

2. The folder at ~/Library/Application Support/NetNewsWire/

The prefs file contains your subscriptions and other preferences. The folder in the Application Support folder contains the database which remembers which items have been read, the disk cache, the Notepad file, Scripts menu scripts, and possibly some other things.

(I’m posting this because I’ve heard from a few people and seen one mention on the web about people not knowing what they need to copy over to their new operating system.)

Also, both Mac Night Owl and Mac Net Journal have posted some good general tips about upgrading. My personal opinion: make backups and go slowly. Your data is too important to lose.

The eighth inning of the Cubs game yesterday stunned me. Sheila said that she had never seen a curse in action before.

I was born in Chicago, so I have some small reason for rooting for the Cubs. Part of me wants to root for the Marlins, because I like Pudge so much and I think the Rangers treated him shabbily. But they’ve won the Series recently and the Cubs very much haven’t.

I’ve posted this NetNewsWire tip before, but I repeat it now and again because new users don’t necessarily know it.

You can make it so that when you open links from NetNewsWire, the pages open in new tabs in Safari. The benefit to this is that you can go through your news, opening links as you go, and at the end switch over to Safari.

Here’s how:

1. Open Safari’s preferences window.

2. Click the General toolbar icon. At the bottom of the window, tell it to open links from applications in the current window.

We posted both NetNewsWire and NetNewsWire Lite 1.0.6fc1 to the betas page.

The point behind 1.0.6 is to fix a performance bug where sometimes HTML descriptions would be slow to appear while a refresh is going on. Otherwise it’s the same as 1.0.5. (Well, we updated the Sites Drawer too.)

Please report to me any deal-stoppers. Thanks!

Once 1.0.6 is out of the way, then the next thing is 1.1, which will have a bunch of new features.

Yesterday I wrote about how Democrats come across as too snobby to be the party of the average guy, and that Republicans have taken over this position.

Some of the reaction to this was people saying that they’re not ashamed of being intelligent and it’s sad that intelligence is a liability.

I agree with that, but I don’t think that’s really the issue.

I think of Bill Clinton. In terms of raw intelligence, he was probably in the top tier of American presidents. But we saw him struggle with weight: he liked McDonald’s french fries. You could imagine that, if he weren’t so busy, he might enjoy watching wrestling on TV now and again. People called him Bubba.

Smart—yes, hugely smart—but no snob. He didn’t set himself apart from the mainstream of American culture, even its trashier parts. He was democratic in the broadest sense of the word.

One of the nice things is that (through the magic of cvs) I can work on NetNewsWire on my laptop. My old laptop—one of the very old two-tone iBooks—was too slow and had too small a screen.

So I’m updating the Sites Drawer while watching the Red Sox and the Yankees. I’m rooting for the Sox. First because I wanted them to beat the A’s, because the A’s beat the Mariners to the division title, and in this series because I’m tired of seeing the Yankees win. (Like many Mac users I habitually root for the underdog.)

I follow politics the way other people follow football. (And sure, I have my favorites, but I have no plans to get partisan on my weblog.)

One thing I’ve found interesting lately is how the Republican party has become the party of the average guy, a position formerly held by Democrats. I’m not sure that Democrats have noticed the switch.

The Democratic party has become—in the popular perception—the party of Rhodes scholars and policy wonks, of complex solutions and nuance. The NPR party.

This goes against the thing many Americans feel: that “all men are created equal” means that no one is smarter than anyone else. Or, if they are smarter, it’s not fair to make other people feel dumb, and it’s not fair to make people feel ashamed of the things they like.

Republicans have as much as promised that they will never make anyone feel dumb. They will never make anyone feel bad for liking NASCAR and domestic beer and Terminator movies and reality TV.

The policies of Democrats may (or may not) be better for the average guy. But getting the average guy’s support is cultural politics. People ask, does this party (or this candidate) “get it,” or do they look down on us?

Aaron Swartz posted a script for Mail.app (Panther version) that moves a message to a folder. The idea is you could set up keyboard shortcuts for moving messages.

I think you could do something similar in Mailsmith, and perhaps in other email apps.

This is a big deal for me—I love how easy it is to move messages in pine and mutt and hate how you have to use the mouse in GUI apps. I do a great deal of message transferring.

What I’d love to see is a GUI app that lifts the feature right out of pine. You type a command key, and then a text field (not in a separate dialog or sheet: too slow) prompts you for what mailbox to save to. There’s a default, but it also accepts typing and tab completion, much like the URL field in a web browser.

It has to be super-fast and completely keyboard driven.

(And you should be able to use the same widget for mailbox navigation. Going to a mailbox is much the same as transferring a message to a mailbox: they’re both choose-mailbox operations.)

At the upcoming O’Reilly Mac OS X conference there will be a special presentation of the winners of the third Mac OS X Innovators contest.

I’ll be there along with some other past winners—Robb Beal, Gus Mueller, and folks from Rogue Amoeba Software—to talk about the current status of our apps and to answer questions about developing for OS X.

In the comments for my previous post about email on two computers, Jerry wrote: “Anything to avoid mutt and pine; they should be permanently retired along with POP accounts.”

I disagree about mutt and pine. In fact, I’m strongly considering switching to one of those two. (I’ve been a pine user in the past, but mutt interests me.)

Mutt and pine have a few of the most important features of my dream email client:

1. Navigating through the mailbox list can be done via keyboard—no mouse required.

2. Transferring a message to a mailbox can also be done with just the keyboard.

3. HTML and text styling is not respected at all.

For example: several times a week I have to copy and paste a styled email from Mail into BBEdit just to be able to read it, since the font size is too small. BBEdit makes it plain text, so it’s in a readable size (a size that I myself set). An email app that does plain text only in the first place would be better.

So... it’s all about spending less time managing email. Anything that can make it faster and easier is a good thing.

I’ve got a new laptop on the way—and I was wondering, for all you folks who have a desktop and a laptop, how do you deal with email?

I’d like to be able to be able to read and send email from both computers without going through the hassle of copying files across.

One possibility I’m considering is running pine or mutt on my desktop, and ssh’ing in to my desktop from the laptop. But then I would miss out on the utility of being able to have two message windows open. And I’d not be able to sleep my desktop when I’m using my laptop.