Tue 12 Jul 2005

Now that's forethought

From Peter Lindberg's Tesugen, quoting Brand's The Clock of the Long Now:

It turned out that in 01829 the Swedish Parliament, recognizing that it takes one hundred fifty years for oaks to mature and anticipating that there would be a shortage of timbers for its navy in the 01990s, ordered twenty thousand trees to be planted and protected for the navy.

I love that kind of thing.

Posted at 2005-07-12 14:13:25 by RichardLink to Now that's foretho…
Comments, trackbacks.

DSLs in Lisp

Bill Clementson posted about Rainer Joswig's example of DSL development in Lisp. This was all prompted by Martin Fowler's article on DSLs.

As well as the interesting discussion of Lisp development environments, and the video (that's a torrent link for a 125MB movie), there is Rainer's observation of the development style that he employed. He termed this “putting parentheses around the specification and make it run”.

There must be something to it, because this is similar to how I approached the development of twinql (though Rainer is discussing a network protocol, of course, and using a lot more mojo!). I wrote an s-expression representation of the queries — SPARQL is a DSL, so this was just a syntactic change — and made them run through decomposition into implementation functions. In the case of SPARQL, the execution involves resolving all of the graph patterns, building up bindings, then doing the ordering/filtering/&c. work, before finally presenting the results.

To accept the actual SPARQL text, I needed a parser, so I employed CL-YACC. After parsing, the results are in the s-expr DSL, and can be run. I found this two-stage process useful, as problems in the parser could be solved by inspection of the s-expr output, rather than execution, and I could develop the query engine before finishing the parser.

It wouldn't be much effort to put an incremental parser on the front end (a SPARQL reader, really) and make the Semantic Web version of a SQL console.

What would I have done in, say, Java? Rainer discusses Fowler's Java DSL example — “better not look at it… it's not really pretty”! Well, the parsing would have been much the same*, but I'd have had less fun throwing lists together (after all, the output couldn't be an s-expression without doing a Greenspun). Actually doing the querying would have required walking over some objects, rather than writing the right functions. I certainly don't think the Java solution would be as clear, and I suspect it would have taken much longer to write.

As Rainer said, it wouldn't have been pretty. I tend to conflate prettiness with elegance — I consider it a good heuristic — so I'd term the Lispy solution more elegant.

* In fact, it would have taken much less time to do the parser in Java, as the SPARQL presentation grammar is automatically derived from a JavaCC grammar! That's a clear demonstration of Java's advantages (whatever you're trying to do, someone's already written it), but also quite promising — even without that enormous advantage, I still would rate the Lisp development process as faster and more satisfying than doing the same in Java.

Give me a REPL any day!


Posted at 2005-07-12 10:20:35 by RichardLink to DSLs in Lisp
Comments, trackbacks.

iSync and the 6630

Apple's iSync has finally been updated to support year-old phones like my 6630. Fortunately it seems to work perfectly (at least for tasks, appointments, and contacts), though we shall see how it deals with time zones, a traditional stumbling block for sync tools. It's quicker than it used to be when syncing my P800, and works without me having to confirm anything on the phone.

One downside I've noticed is that the 6630 is very slow at displaying the thumbnails for contacts (perhaps only until they're cached?), and these are always synchronised — so I either have a slow Contacts application, or no pictures on my Mac. Hmmm.

Want to know what the worst sound in the world is? Power cable snapping taut against your foot, followed by iBook hitting floor. No harm done, or so it seems. That beats falling trees and “the lamentations of the women” any day of the week.

(Actually, it sounds like I've damaged the left speaker, turning what was previously bad sound quality into actively painful. Hmm.)

Posted at 2005-07-12 07:54:32 by RichardLink to iSync and the 6630
Comments, trackbacks.

I can see my house from here!

Mobile Monday tonight. If it were next week I could walk!

In other news, Vidar's been writing interesting and rational responses to the recent terrorist attacks on London. Oh, and this looks cool — a graphical social fabric for representing your social world on your PDA.

Posted at 2005-07-12 05:03:27 by RichardLink to I can see my house…
Comments, trackbacks.

Google
Web holygoat.co.uk
  • richard is: