A Trifle Absurd
Matthew Morgan’s software notions
I (Still) Want an Editor
28 March 2006 at 19.31 • in Mac, Programming, OverleafI want a Mac-native text editor that supports:
- syntax-aware automatic indenting
- syntax-aware search (project-wide, both “find definition” and “find all uses”)
- arbitrary programming languages
- proportional fonts
Is that too much to ask? Apparently, yes. I haven’t found a single editor that implements all four. TextMate can’t handle proportional fonts. SubEthaEdit can’t indent intelligently. XCode isn’t extensible. Et cetera.
All this is reminding me why I started working on Overleaf. Too bad I don’t have time for it right now. Maybe I’ll get back to it in the sweet by and by after I ship Trifle.
Breaking a Retain Cycle
23 March 2006 at 15.53 • in ProgrammingToday I came across a retain cycle that Cocoa’s usual conventions can’t break. Trifle’s collections keep their items in an NSMutableArray, and items keep their collections in an NSMutableSet. Since Cocoa collections always retain their members, this creates a cycle.
I toyed with the idea of allowing the cycle, and then breaking it with careful manual deletion. But that’s way too easy to get wrong, especially with the undo manager in the picture.
An NSValue can contain a nonretainedObjectValue, so I could store NSValues in the set instead. The NSValues would be retained, but the collections inside them wouldn’t be. The extra layer of indirection would be a bother, though.
NSHashTable is a better answer. It’s a non-object data structure that provides the same functionality as a mutable set, but lets you specify whether to retain/release member values. The only catch is that I’ll need to write a few simple methods to expose it to key-value coding (search for “unordered” in Tiger’s release notes to learn more).
Of course, life would be better if I didn’t have to spend time thinking about retain cycles. Cocoa does a decent job papering over the limitations of reference counting, but I’d still rather have real garbage collection.
Update: An even better solution for this problem is to use toll-free bridging. CFSetCreateMutable(NULL,0,NULL) gives me a non-retaining set that I can just cast to NSMutableSet and use.
Exceptions to Every Rule
13 March 2006 at 18.55 • in TrifleAn answer to my rule dilemma: declarative rules with exceptions. A collection is defined by declarative rules in the same way as a smart playlist. But items can also be added and removed manually, creating exceptions to the rules.
At the implementation level, each collection tracks two sets of exceptions. One set contains items to always include, because the user put them there. The other set contains items to always exclude, because the user took them out. There are a few corner cases that get tricky, but overall, it’s not too hard to do the right thing.
This approach abolishes the distinction between regular collections and smart collections. Instead, those two cases become endpoints of a continuum. A regular collection is just a collection with no rules (only exceptions!). A smart collection is just a collection with no exceptions (only rules).
Now that I’m thinking in these terms, I’ve realized that this is part of the plan for Chandler’s collection model. So this isn’t an original idea. That’s a good thing, though: if nobody was using this model, I’d drive myself crazy trying to figure out what fatal flaw kept people from using it in their apps.
Declarative vs. Imperative Rules
10 March 2006 at 12.38 • in TrifleShould Trifle’s rules be declarative or imperative? I’ll give examples instead of definitions: spreadsheet formulas and smart playlists are declarative, while email filter rules are imperative.
Declarative rules are the success story of end-user programming. Millions of nonprogrammers create and use them daily. But in the form of smart playlists (and their smart-* kin), they have some problems. For instance, they make it hard to fine-tune their contents. If the query for a smart playlist gets you almost there, the only way to get all there is to either tweak the query some more (add or remove conditions) or tweak some items (change them to fit/not fit existing conditions). The Chandler folk have been wrestling with this, trying to come up with a more flexible model.
Imperative rules are much more flexible. Lotus Agenda provided powerful imperative rules that could be triggered by various actions. But that power and flexibility had a price. As Agenda’s creators said, “The results of cascading program-initiated actions often surprise even experienced users…” And surprise is a Bad Thing here.
So I’m not happy with either approach at the moment. To use Adam Bosworth’s terminology, declarative rules are simple but not sloppy, while imperative rules are sloppy but not simple.
Rules Redux
10 March 2006 at 11.31 • in TrifleI’m having second thoughts about cutting rules. My arguments against them don’t seem convincing anymore.
“Rules are a major schedule risk.” Yes, but I’m not on a particularly tight schedule. Sure, I want to ship expeditiously, but a few months either way won’t make a big difference.
“Rules need to be done right or not at all” — otherwise I’d be stuck supporting a broken rule model. But I think this is actually an argument for rules. By designing rules now, in concert with Trifle’s overall data model, I have a better chance of making a single coherent system.
“Trifle will still be a useful application without rules.” True. But the question is whether Trifle will be a distinctively interesting application without rules. I doubt a simple list/table editor would generate much if any buzz, and for a shoestring operation like mine, no buzz means no sales.
Besides, the whole reason I started this experiment of independent development was to create an innovative and useful app. If I reduce that to a lowest common denominator by eliminating the tricky-but-interesting features, not only will I fail to excite potential users, I’ll fail to excite myself. And that will quickly suck all the fun out of this (ad)venture.
So now I’m in design mode, trying to find a rule model that works. It’s a frustrating endeavor, ’cause I don’t like any of the solutions I’ve found so far, and I don’t feel like I’m making much progress. But that, too, was part of the reason I started doing this: to find a challenge.
Booklog: February
1 March 2006 at 13.42 • in BooksFiction
- Busman’s Honeymoon — Dorothy Sayers
- The last Lord Peter novel; my only disappointment is that I don’t have more of them left to read. The mystery itself is downplayed in favor of character relationships, but Sayers again makes it work.
- Lord Peter — Dorothy Sayers
- A collection of all the Lord Peter short stories. I’d read most of them before, but saved the last two (involving Harriet and the Wimsey children) till now.
Nonfiction
- The Last Word and the Word After That — Brian McLaren
- McLaren concludes his trilogy of fictionalized dialogues (that started with A New Kind of Christian) with thought-provoking ruminations on hell.
- Take and Read — Eugene Peterson
- An annotated bibliography of Eugene Peterson’s favorite books. As you might expect, most if not all of his picks have a theological angle.
- Purple Cow — Seth Godin
- I kept hearing kudos for Seth Godin’s books on marketing, so I finally read one. I liked it: it’s rare to find a business writer with writing ability and something to say.