Tuesday, November 13, 2007

On the prospects of creating a headless Firefox

I've often wondered how hard it would be to make a headless version of Firefox. HTTPUnit is nice and all but if you want to ensure that everything is behaving as it does in a real browser there's nothing better than using a real browser.

So setting aside all questions as to difficulty does the idea of a headless Firefox even make conceptual sense? You'd at least need some way to script or control the behavior externally. But let's imagine you designed a feature where by hovering over an event you triggered an Ajax request or caused some DOM fragment to be constructed on the fly. In order to get the headless browser to do that you'd need to either have to tell it to simulate the mouse movement or tell it to artificially fire the hover event for the element in question.

Tuesday, October 30, 2007

(Lesser known) things I like about Leopard

  1. Calculator.app sports a fully functional RPN mode. It's had RPN mode since Panther but it always seemed like a shoehorned afterthought. Switching to RPN never produced any change in the UI and RPN really demands a multi-line display. Now it has one. There's one quirk I've noticed: when you type a number and press enter, the number gets pushed up the stack (as it should) and then gets duplicated on the line below (not as it should). As soon as you begin to type a new number, the doubled entry disappears but it should never have appeared in the first place.
  2. Calculator.app can now also display digit seperators.
  3. The Airport menu (from the drop-down in the menu bar) now shows lock icons next to those networks which are protected. You can see at a glance if there are any available networks that are open.
  4. Hitting command-backspace from any NSTextEdit field will delete from the cursor to the beginning of the line. This means TextEdit gets the "feature" I most miss when I'm away from TextMate.
  5. iCal.app no longer changes the size of your window when you switch from (say) month view to week view.

Wednesday, October 24, 2007

ECMAScript 4 Overview (final draft)

The final draft of the Overview that describes what's going to be in Javascript 4 (E4) is online as a pdf.

Interestingly, this represents a point of departure from previous Javascript updates in that the group will provide a "reference implementation" in ML! And I though all that time I spent working in ML back in college would surely go to waste.

You can grab the standard SML release for Mac (as a DMG even) from here.

Thursday, September 13, 2007

Bike to Work

I biked to work last Friday. No different from any other Firday at previous jobs except that I now work 42 miles from home. So my commute took 3 hours.


View Larger Map

Download the KML file.

Monday, July 09, 2007

New Job (@ Google!)

I've started a new job at Google!

Wednesday, March 14, 2007

BBEdit Comes Around

We programmers spend a lot of time editing text and tend to feel pretty strongly about the relative merits of various text editors. For the better part of two jobs - spanning nearly four years - I lived and breathed in BBEdit, “the programmer’s text editor”. It’s always seemed like a good product but even then it was already quite old and it seemed like its designers were resting on their laurels somewhat. The interface looked about the same as it had when my friend was using it in college on OS 9 back in 1998. There didn’t seem to be much work going on to create innovative features or even to copy ones that had started to crop up in other editing programs. But it still had an impressive feature list and at the time was by far the best tool for creating HTML/XML/CSS on Mac OS X.

But somewhere along the way I noticed TextMate. I saw a screencast for some Ruby on Rails demo and they were using snippets - type a keyword, hit some expansion key, get a whole bunch of templated text for free. I didn’t know the TextMate name for it but I knew the feature: it was the thing I most missed from a Java editing program that was a one time favorite on Windows. I decided to give TextMate a try even though it wasn’t free and even though I’d already shelled out big bucks for BBEdit (well, truth be told, the Reagents of the University of California shelled out the big bucks for BBEdit).

Over the years I’ve probably married about a dozen different text editors so it’s not a tremendously big deal for me to switch to something new. The muscle memory takes a little overcoming but it’s nothing horrific, especially if you’re not also switching platforms to something where the modifier keys are totally different.

It didn’t take long before I was hitched to TextMate. With the exception of occasional forays into emacs I’ve been using it exclusively for about 2 years. I switched and never looked back. Until today.

I was reading a blog which suggested that BBEdit had finally updated their interface so that it looked less out of place on OSX than does a disco ball at a funeral. So I downloaded the trial version (8.6) and gave it a spin.

There’s plenty to like

  1. The icon looks less like ass. I was using BBEdit when they switched from their chestnut of an icon to something that looked like a beta placeholder for the image it was replacing.

    classic

    Either the whole thing was a play from the people that brought us New Coke and Coke Classic or they’ve seen the light: the newest version looks like the old except rotated a few degrees.

  2. Rumors of interface polishing are true. The changes are rather minor but still welcome.

  3. They’ve revamped their Glossary tool. Now it’s called Clippings and it works much like snippets in TextMate. The expansion key (F5) is a little awkward, especially on laptops. And where TextMate allows you to cycle through various pre-defined locations in the expansion text by repeatedly pressing the the same key (tab) that expanded the text in the first place, BBEdit uses Ctrl-` to cycle through positions. F5 still seems like a bad choice but having a different key command to cycle through the positions actually seems like a good idea. One annoying thing about TextMate’s snippet system is that you can’t expand a snippet if you’re still tabbing through the positions of a snippet you just expanded. It will interpret “tab” as a request to move to the next position instead of searching for an expansion. The BBEdit team seems to have made a better choice in this matter.

  4. They’ve added support for a few more languages including Markdown and, get this, SQL. Yeah, it’s 2007 and they’re just getting around to adding SQL. Still they did it well and have support for multiple SQL variants like PL/SQL and MySQL.

  5. They’ve added a preview window just like TextMate and SubEthaEdit. If you keep it open while you type it will refresh the preview automatically whenever you stop typing for a second or two. You don’t need to save the document to use it. Yeah, it’s just like TextMate and yes, it feels like they’re copying but it’s still a worthwhile addition.

  6. Code folding. I make very little use of this feature but I’m sure it has its fans.

As long as they were out copying features I wish they’d copied a little more. There is still no equivalent to TextMate’s themes. The syntax highlighting engine still doesn’t support things like making keywords boldface. It still has pretty poor support for editing files with mixed languages (like PHP inside HTML). It still needs an organizational concept as functional and powerful as TextMate’s bundle system.

I’m not going to move back to BBEdit any time soon but these recent changes are enough to entice me into checking back on it in a few months. If nothing else, BareBones seems to have recognized that they’ve been squandering their name recognition and an enormous lead and that if they want to remain competitive they’ll need to start making radical changes. I think they made a couple of large mistakes when they moved to OS X. They ported the code but didn’t seem to do much to avail themselves of all that Objective C and Cocoa would provide. Even if they wanted to exploit the undeniable advantage of their extensively optimized and highly debugged text engine, they should have recognized that the arrival of OS X meant that others less encumbered than they would be able to make full use of everything from XCode to Cocoa to Objective C to the UNIX shell, and that this might allow a hypothetical upstart to move so quickly that any initial lead could evaporate before you could say “reality distortion field.”

Tuesday, March 13, 2007

Pardon the interruption

I am typing this entry using MarsEdit 1.1.5(207), of which I just downloaded a trial version. It seems you can edit your posts in whatever text editor you choose but I need to see if I can specify that markdown formatting is to be applied as part of the post procedure or if that’s something that’s only available while you’re previewing your post in MarsEdit.

This sentence should begin a new paragraph and this word should be italicized.

Update: it turns out markdown syntax is recognized by MarsEdit’s built-in preview window but there doesn’t seem to be any way to configure it to run your post through markdown prior to submitting it to your blog. Even more mysterious, there doesn’t seem to be any way to manually convert your markdown-formatted post into HTML suitable for posting. It’s lucky that I have a licensed copy of TextMate and that MarsEdit will allow me to edit my post there.

Thursday, March 01, 2007

iTerm goes full screen

I started using iTerm pretty regularly at work a few months ago because it supported multiple tabs. I flirted with the program long before that but it seemed too unstable back then so I gave it up and went back to Terminal.app. The stability has improved a lot since then but there has always been one feature I found missing: full screen support.

Until now.

I didn't even notice when it happened but the most recent versions of iTerm now sport a great full screen mode.

Like a lot of programmers (and sysadmins) I spend a good deal of time working in a terminal. At work, a lot of us do. The crowd seems to be split between:

  1. those who think full-screen mode is the coolest thing since screensavers
  2. those who make fun of the first group

I'm such a fan of full-screen mode that I've long kept GLTerminal on my machine just for those instances where I want to work in a terminal without any distractions.

Wednesday, January 31, 2007

XSL[T|-FO]

My friend (and co-worker, and constant source of distraction) Kirt was poking around the company intranet today and came across a document detailing interview questions for “XSLT Developers”. When I was doing Java for a living I used XSLT quite a lot and eventually became quite good at using it effectively. Naturally, I was curious to see what we had to say about the qualifications of a good XSLT developer, especially since as far as I know, we don’t now, nor have we ever, used the slightest bit of XSLT for any part of our entire system.

Using the document to conduct an actual interview would have made for a pretty miserable experience which - since we’ve never used it and are unlikely to ever use it - I’m okay with. But it reminded me that there is a lot of confusion about what XSLT is and isn’t. XSLT and XSL are not synonymous. XSLT is a language for transforming XML documents. XSLT is but one of two components of the larger XSL, the other being XSL-FO: which is a language for specifying visual display. XSL is just a unifying term, a shorthard for saying “XSLT plus XSL-FO.” Wikipedia’s article on XSL disagrees with at least two points here but I won’t go into it other than to say that Wikipedia (though I love it so) is wrong.

I think that part of the reason why XSL and XSLT are used interchangeably is that in the beginning, XSLT pretty much was all of XSL. Sure, XSL-FO was envisioned early on but it took a long time to get a standard and it took a really long time to get an implementation. XSLT had a standard and multiple implementations while XSL-FO was nothing more than a dim idea. If you started using XSLT back then, you could be forgiven for thinking that was all there was to XSL.

The other point of confusion about XSLT is that it’s nothing more than a glorified variable substitution engine with horrid syntax. It’s syntax is retched and you certainly can use it to simply plug variables into an output template but XSLT is a lot more capable than that. It took me a long time to see and even longer to really understand that XSLT is basically a functional programming language.

Monday, January 22, 2007

lisp on OS X

I’ve decided (finally) to learn lisp. I don’t know if it will make me a better programmer but if even half of what Paul Graham says about it is true, it has to be the best programming language ever written. =)

Mac OS X doesn’t ship with a lisp interpreter but there are several free implementations out there. After ruling out the ones that cost money and the ones that have icky IDEs that run in X11 and the ones that depend on things like Fink, you’re really only left with two options.

  1. Clozure CL (formerly known as OpenMCL)
  2. SBCL (Steele Bank Common Lisp)

I went with SBCL because it works on both PowerPC and intel. Installing it is pretty easy. You do need to have the Developer Tools installed on your computer as the install process makes use of gcc.

  1. Download the “binary” for the platform of your choice
  2. Uncompress/untar the bz2 file
  3. Fire up Terminal.app
  4. cd to the directory that you extracted from the tar file
  5. Run the following commands:
    INSTALL_ROOT=/usr/local
    sudo sh install.sh

That’s all there is to it. At this point you can run the lisp interpreter (sbcl) or bring up the man page for it.

UPDATE (27 August 2008): Clozure CL now supports both PPC and x86-64. CCL has always had better integration support for Mac OS X so it may now be a better choice for Mac users than SBCL. I haven't used it much but I plan to put it through it's paces.

Wednesday, January 17, 2007

Sunnis and Shiites

If you pay attention to the news, it’s nearly impossible to go a day without hearing about Sunnis and Shiites. Assuming you start out knowing nothing about them, it only takes a few news stories to figure out the most pertinent facts: they’re Islamic groups that seem to hate each other. But the news outlets never tell you anything about why Sunnis and Shiites don’t get along. If you want to understand that, you have to do a little research of your own.

The best and most succinct description I’ve read comes from Thomas L. Friedman’s From Beirut to Jerusalem

The Muslims of the world have long been divided between Sunnis, who are the majority, and Shiites. In the seventh century, shortly after the death of Islam’s founder, the prophet Muhammad a dispute arose over who should be his successor as spiritual and political leader, known as caliph. One group, the majority, argued that Muhammad’s successor should be appointed through the process of election and consensus by the elders of the community, as was the tradition of the desert. Sunna in Arabic means tradition, and those who held this view became known as the Sunnis.

A minority faction, however, argued that Muhammad’s successors should come exclusively from his own family and their descendants. They insisted, therefore, that his first cousin and son-in-law—Ali—be appointed as leader of the community. Those who held this view became known in Arabic as the Shia or “partisans,” of Ali. The Shiites were clearly influenced by the notion of divine-right monarchy of pre-Islamic Persia (Iran). The Sunnis eventually defeated the supporters of Ali and installed their own chosen caliphs. Nevertheless, the Sunni-Shiite split has continued down through the ages of Islam, and a whole body of theological and even cultural differences developed, distinguishing Shiites from Sunnis. Summarizing these differences, Islam expert Edward Mortimer observed in his book Faith & Power: “Sunni Islam is the doctrine of power and achievement. Shi’ism is the doctrine of opposition. The starting point of Shi’ism is defeat: the defeat of Ali and his house…. Its primary appeal is therefore to the defeated and oppressed. That is why it has so often been the rallying cry for the underdogs in the Muslim world … especially for the poor and dispossessed.”

Iraq happens to be one of only two Islamic countries (Iran is the other) where the Shia constitute a majority of the population (about 60 percent). This does nothing to help explain the Iran-Iraq war but does help illuminate why many other Islamic states seem supportive of the Sunni insurgency.