TruerWords Logo
Google
 
Web www.truerwords.net

Search TruerWords

Welcome
Sign Up  Log On

“A New JS Mode for Emacs, and Why I Wrote a JS module for BBEdit”

From: Seth Dillingham In Response To: Top of Thread.  
Date Posted: Monday, March 31, 2008 1:02:49 PM Replies: 2
   
Enclosures: None.

Stevey's Blog Rants: js2-mode: a new JavaScript mode for Emacs

For the OOD-loving and API-minded among you, the "beautiful" way to do syntax coloring would have been to finish parsing, then walk the AST using a Visitor interface, applying the coloring in a second pass. I tried it, and it was, as they say, "butt slow". In fact (perhaps not surprisingly) walking the AST takes exactly as long as parsing, so it was twice as slow as doing it inline.

So I bit the bullet and moved my syntax-coloring to happen inline with parsing. Fortunately it only introduced about 30 lines of code to the 4000-line parser/scanner, because most of the coloring happens in the scanner, at the token level. Go figure.

Steve Yegge describes (at length) his new JavaScript mode for Emacs. For much of the article he's talking about (trying to) parse the JavaScript file at the same time that he's applying syntax coloring. It's absolutely NOT a simple task, not by a long shot. He had the benefit of direct access to Brendan Eich (the author and maintainer of JavaScript itself) at least twice so far, but still describes how difficult it was. And this is someone many people consider a superstar programmer who has been working at Google for years.

Well, next to Conversant, my favorite-ever project is/was the JavaScript module in BBEdit. I won't go into all the technical details like Steve does, but I will say, "I feel his pain."

Thinking about this, I realized that I never wrote the story of how I came to be contracted with Bare Bones. With all the explosives experts, martial artists, photographers, and "connected" individuals at BB I need to be careful not to cross the lines of my NDA, but I think I can tell this story safely. ;-)

How It All Started

In early Spring of 2006 — almost exactly two years ago — I was doing a lot of work with JavaScript. Prototype was my new favorite toy, but 1.0 hadn't yet been released. My editor of choice was BBEdit, but I was frustrated that it didn't list the functions in Prototype.js (follow that link for more details, including pictures). I wrote to Bare Bones tech support to ask if they knew of any third-party, BBEdit, language modules for JavaScript.

The answer was "no," but I was told that a couple other people had asked about improvements to their JavaScript support. I wrote back to say that I'd like to take a crack at it, if I could only see "the source to the current syntax module." Hah. Yeah, like that was ever going to happen. "Could you send me some of the source to your app, so I can write something better?" (That's NOT what I said, but that's probably what it sounded like.)

After lots of email back and forth, on May 10th we had only reached the point where Bare Bones was "planning to update it in a future release." I'm a developer, I know what that means. So I wrote again, and said I was going to start my own language module (based on BBEdit's public SDK for language modules), and could they just send me their current list of language keywords?

A month later, Rich himself finally sent them to me. That was June 12th. I wrote back with a better list of keywords, and told him I was going to start working on my own module unless they told me I shouldn't bother because they already had one under development. They didn't, but Rich seemed to be trying to call my bluff: you go ahead and start working on it, and if you come up with something good maybe we'll work something out. (I've been on both sides of this discussion, and I know that usually nothing happens.)

Three days later, I sent them a copy of a fully functional JavaScript language module, written in C++. (Looking back, I'm all impressed with myself!) When I'm telling this story in person, especially if Rich is nearby, I like to say that they tried to call my bluff but found I wasn't bluffing. I still think there was a little of that, but mostly I think they just dealt with this nagging, mostly-unknown customer the best way they could: "go ahead and do your thing, and yes, maybe we'll work something out."

A few days after that I sent them another one, with some more features and some bugs fixed.

A few days later, I went to RailsConf in Chicago, and found out that lots of Rails developers were using TextMate. I'd barely heard of it! (Probably because I don't go looking for new toys very often when I have work to do.)

While at the conference, I talked to other JavaScript devs about their editors, and showed them what I'd done for BBEdit. I even showed Sam Stephenson, Prototype's author, at the same time that I was showing him what I'd done for custom events in javascript. Everybody liked it, and it was definitely better than anything else out there. I also asked people why they were using whatever editor they were using. Most of the Rails folks who were using TextMate were using it because that's what the top Rails guys recommended, and because it had really good integration with Rails itself.

I wrote up all this "research" and sent it to Bare Bones when I returned home.

Writing the language module, peppering them with lots of email, and sending in the research I did at RailsConf were enough to really get their attention. In early July (can't remember... July 3rd or 5th), Rich came down here and we had lunch at Costello's Clam Shack, right on the water. I got an early look at BBEdit 8.5, we talked about my 1,001 feature requests, and I signed an NDA with a handshake (and later with pen and ink).

Perhaps as import as the business that was done that day, Rich and I became friends (and have had a casual breakfast almost every Tuesday morning since then).


Discussion Thread:
Trackbacks:

There are no trackbacks.



TruerWords
is Seth Dillingham's
personal web site.
Read'em and weep, baby.