A Trifle Absurd
Matthew Morgan’s software notions
Domain-Specific Languages, Smalltalk-Style
31 May 2005 at 18.14 • in Languages, OverleafI recently chose F-Script to specify Overleaf syntax-highlighting modes. Since then, I’ve been experimenting with ways to build a domain-specific language (DSL) in F-Script.
F-Script is essentially a dialect of Smalltalk, and Smalltalk has a tradition of embedded DSLs. I’m used to building DSLs with macros, but I had to change my mindset: Smalltalk doesn’t have macros; instead, its message-sending (read: function-calling) system is extensible enough to make up for it.
I played with different variations for a while, trying to find a scheme that would minimize extraneous punctuation and parentheses. I came to appreciate Smalltalk’s weird precedence rules just a little: they make math expressions odd (1+2*3 is 9 in Smalltalk, unlike virtually all other infix languages, where it’s 7), but if you’re defining your own operators, they make things (relatively) simple. And by defining a few key operators, I came up with a simple, easy-to-read DSL that doesn’t have to stoop to regular expressions to define lexical syntax.
Side note on operators: I’m no big fan of operator overloading — it almost always obscures what an expression is actually doing — but defining new operators is another matter. A new operator won’t get confused with the meaning of an old one, but can simplify code quite a bit. Haskell’s operator system is still the best I’ve seen: you can define new operators at will, use existing functions as operators (via backquotes), and control operator overloading using typeclasses. Good stuff.
Housekeeping
28 May 2005 at 19.30 • in AdminIf you’ve ported a Blogger blog into Wordpress, you might want to double-check the internal links between imported posts. I just had to go fix all of mine. The Wordpress importer had left them in Blogger-style “/yyyy/mm/post-title” format, rather than “/yyyy/mm/dd/post-title”.
I decided to ditch the ads in the sidebar: they caused a page-loading flicker, and were rarely relevant to the actual content. I only added them in the first place for page-view statistics, but now that I’m on a full-blown hosted account, stats are plentiful. In fact, I discovered the above broken links while perusing the server log. Web bots make great link checkers, don’t they?
Oh, it turns out I didn’t have Previous Page/Next Page links in my template, so you couldn’t read more than ten posts from a particular month. That’s fixed now, too.
Implementing Trifle
25 May 2005 at 22.30 • in Trifle, MacIf Trifle’s going to be a taggable, searchable, versioned, and tailorable data store, how should I implement it? I don’t want to create yet another walled city of data, so Trifle should interoperate like mad with everything around it: applications, Quicksilver, Dashboard, Spotlight, the command line, you name it. So, it needs to tie in to platform-specific frameworks at a basic level — which means that Trifle will be Mac-only. (Question answered.)
Thus, I get the full smorgasbord of OS X features to choose from, without being chained to the lowest common denominator. I can build a Cocoa UI, rather than being limited to DHTML. (This doesn’t preclude an add-on Web interface, but it would require the server to be a Mac.) I can use Spotlight APIs to do full-text search. Who knows, I might even do something crazy with union filesystems.
It feels strange to pick a particular OS to develop for. Under Windows, and even Linux, I never felt enough at home to put down roots. On OS X, I do; I haven’t enjoyed a platform this much since the Commodore 64.
Rethinking Trifle
24 May 2005 at 22.22 • in TrifleI tried to whittle Trifle down from a big vision to a small, implementable piece. The result was essentially a del.icio.us replacement. Not only is that less than inspiring (after all, del.icio.us does get the job done), it’s far removed from the goals I talked about in my first post. So I’ve been rethinking Trifle from the ground up.
The gist is this: I want a data store that’s taggable, searchable, and versioned, and I want a UI that is (to borrow Oval’s phrase) “radically tailorable” by end users.
Taggable: Tags replace location-based metaphors as the primary organizing scheme. Anything can be tagged with anything, and tags can have multiple components (subsuming field-value and hierarchical-path data). Some items in the system may consist of nothing but a set of tags.
Searchable: Really, this needs no justification — any decent data store ought to be searchable. Search by tag, by contents, or both.
Versioned: “Save” is eliminated. Changes are automatically persisted, but you can revert (or peek back) to an earlier version of an item, and bookmark any version with a particular significance.
Tailorable: Build an interface to organize your stuff however you want. As in a spreadsheet, a range of customization is supported, from minor tweaks to full-blown new applications. (See my last post for some prior art in this area.)
So that’s the ‘what’. The ‘how’ has changed too, but that’s tomorrow’s post.
Oval, Agenda, Hypercard, and…?
23 May 2005 at 18.26 • in Programming(via Patrick Logan) Experiments with Oval describes a system that gives end users the tools to build their own groupware applications by manipulating objects, views, agents, and links. The authors’ goal was to provide the same kind of “radically tailorable” environment that spreadsheets do.
Oval wasn’t the only project pursuing radical tailorability: Hypercard and Lotus Agenda did it too, in their own domains. But the rising tide of the Web seems to have swamped this area. Where are the projects doing this today? Who’s out there trying to build systems that let end users build their own systems? Spreadsheets defined a nexus of power and simplicity — surely there must be other areas besides calculation that could benefit from tools on a similar level.
F-Script as Configuration Language
20 May 2005 at 17.22 • in Languages, Programming, OverleafI’ve been using simple property-list files for Overleaf editor modes. They work fine for specifying string-delimiter characters and such, but I knew I’d eventually outgrow them. So today I decided to hash out just what an Overleaf mode file looks like.
I quickly felt the tug of the XML gravity well. I didn’t want to write an ad-hoc parser, and I wanted my format to be extensible, so I sighed and assumed that I’d be stuck with XML as my format. But when I started sketching out an example, I realized that it looked a lot more like a program than a data file. I thought of F-Script — but of course an interpreted language would be way too slow to implement tokenizers.
Then I had my light-bulb (and/or head-smack) moment of the day. I don’t have to write tokenizers in F-Script, all I have to do is make a configurable tokenizer and use a chunk of script to initialize it. The F-Script code runs only once, when the mode is loaded. In essence, the script statements to set up the tokenizer are a DSL, and the resulting tokenizer object is a compiled representation. And mode-writers can use variable binding and other F-Script constructs to make their code clearer, without affecting runtime speed.
Keeping Time
19 May 2005 at 23.21 • in ProductivityI’ve been keeping a daily log for the past month. I started out intending to collect data about my procrastination patterns (along the lines of the Now Habit procrastination log). To my surprise, I’ve discovered that just keeping the log is a great productivity hack.
All I do is fill in a sheet of notebook paper as the day goes along, with three items per line: the start time, a brief task description, and the elapsed time for that task. When I switch tasks, I write down the elapsed time for the previous task, the new start time, and the new task. At the end of the day, I add up the “real work” tasks to see how much time I’ve spent working.
Simple, right? So why has my productivity shot up? I still don’t really understand it, but I have a few ideas:
First, it’s liberating. I’ve tried and failed many times to impose a system or schedule on my daily work, but this experience is showing me I don’t need to make up rules to be productive. I just write down what I do and how long I do it for. Instead of burdening myself with a guilt trip of rules and schedules, I get to look back and celebrate how much work I’ve done.
Second, it’s encouraging. I can look back at the past few weeks of logs and see how much solid work time I’ve put in. It’s also evident that even when outside commitments cut into a day, I can still get plenty of work done.
Finally, it’s focus-inducing. By writing down each new task as I start doing it, I become more conscious of each task-switching decision, leading to better task choices. Also, I make a small but significant commitment to the new task just by writing it down, and that’s usually enough to get me over the starting hump and into productive work.
I don’t know if this would work for lots of folks, or if it was just the right thing at the right time for me. But it’s simple and easy, so if you’re looking for a life hack, I say give it a shot.
Learning to Love Multiple Windows, Again
18 May 2005 at 21.42 • in MacAs an X11 user in college, I took meticulous care in laying out a bevy of windows on the screen. If my current window manager wouldn’t do what I wanted, I’d just switch to a different one. But when I wound up in a Windows environment after graduating, it was easier to just maximize everything and use one app at a time. (Windows was far less tweakable, and I had lost patience for tweaking in any case.) The advent of tabbed windows only reinforced that tendency.
Now that I’m on the Mac, though, I find myself not only using multiple windows, but enjoying them. It’s the best of both worlds: I can use multiple windows simultaneously, but I don’t have to spend time tweaking window layout. Part of that is just because I have way more screen real estate, but it’s the array of window-management methods that really make it shine: direct manipulation, Exposé, Quicksilver, window hiding, and even the Dock.
This is starting to affect my workstyle at a deeper level. I’m running more applications at once, because it’s so easy to get windows out of the way yet still have them readily at hand. I’m using more simple, single-purpose applications (like Cocoalicious), instead of all-in-one behemoths. I didn’t expect that, but I sure am enjoying it.
There Is No Shelf
17 May 2005 at 16.33 • in General, TagsClay Shirky states the case against ontology once more, with his usual good sense: “…if you’ve got enough links, you don’t need the hierarchy anymore. There is no shelf. There is no filesystem. The links alone are enough.”
There is no shelf. We can organize the virtual world any way we please. Most metaphors we have now, though, are based on physical models. It’s time we got more creative, and started building interfaces that work in ways that physical reality cannot.
The files-and-folders (desktop) interface was based on a physical model to make it easier to learn. Will nonphysical models be harder? Not necessarily. Take the spreadsheet, the all-time success story of a new conceptual model. At a glance, it has the reassuring familiarity of a piece of lined paper, but type in one formula and you enter a new world. The real conceptual model of a spreadsheet has no physical analog at all — yet millions can and do use it.
The Joys of a Well-Defined Project
11 May 2005 at 17.53 • in Trifle, Overleaf[Two weeks without a post? I have an excuse (really!): I was in Delaware for my sister-in-law’s wedding.]
Working on Overleaf feels liberating, and I think it’s because it’s such a well-defined, tractable project compared to Trifle. Trifle is a big, vague, experimental project: most of the work is in defining the project and actively trying to innovate. Overleaf, on the other hand, is an instance of a well-defined category, the text editor. Its basic feature list is obvious, and the implementation choices are highly constrained (for instance, syntax highlighting needs to be fast, so it can’t be done in a scripting language).
The result, in Overleaf’s case, is a rapidly advancing codebase, with visible progress on a daily basis. Even in the area where I hope to innovate (highly configurable text typography), the feature design is clear, and the implementation decisions are few.
And even though Trifle is on hold temporarily, I’m betting that my Overleaf experience will pave the way for it — especially what I learn about releasing and promoting open source apps, when the time comes to let Overleaf loose. Until then, though, I’m having a lot of fun hacking away.