js2-mode: a new JavaScript mode for Emacs — cover art: a single warm Emacs window at evening rendered as a small storybook printer's case, with a typed JavaScript fragment laid in beautifully coloured wooden type and a perfect syntax-tree of fine wire branching above it. 🤓

2008 · Stevey's Blog Rants · Announcement

“This mode includes a recursive-descent parser that I ported from Mozilla Rhino. That means it's always right. It doesn't use heuristics or guesswork; it's exactly the same parser used by JavaScript engines.”
— From js2-mode: a new JavaScript mode for Emacs, March 2008
Read the essay

© 2008 Steve Yegge. Originally published at Stevey's Blog Rants.

AI Notes

The rare product announcement that spends most of its length on the parts that failed. Steve ported four thousand lines of parser and assumed the hard work was behind him. Then incremental parsing ate a couple of weeks before he gave up (Brendan Eich's polite "let me know how the incremental parsing goes" turns out to have been a warning), and indentation ate a month before he renamed the wreckage doomed-indent.el and started over. The unglamorous problems were the expensive ones: GNU Emacs carries roughly 27,000 lines of Lisp dedicated almost entirely to indenting C-family code, and by the end of this project Steve understood why. What rescued the mode was a 200-line indenter by one Karl Landström, whose diacritic-mangled surname becomes a running gag, plus a TAB-cycling "bounce indenter" borrowed from python-mode.

One irony the post couldn't see coming: the "2" was a bet on JavaScript 2, the ECMAScript Edition 4 future the essay links to with a straight face, and the standards committee abandoned ES4 within months of publication, so the misnomer Steve promised was temporary became permanent. It ends with a piece of purchasing advice no product announcement is supposed to include.

Related listings

  • 2008

    Ejacs: a JavaScript interpreter for Emacs

    The companion project — same year, same parser, same goal. js2-mode is the editor; Ejacs is the interpreter. Both are pieces of the same plan to let Emacs people write extensions in JavaScript instead of Elisp.

  • 2008

    XEmacs is Dead. Long Live XEmacs!

    Same month, same Steve, same Emacs subculture — the eulogy for XEmacs. The two posts together are a snapshot of where the Emacs world stood in spring 2008.

  • 2008

    Emergency Elisp

    Steve's crash course in writing Elisp under duress, from earlier the same year — the prose context for the kind of programmer who would happily port a Rhino parser to ten thousand lines of elisp.