we get signal

2007-12-08

Steve Yegge on improving Emacs with JavaScript

(tags Emacs, Lisp, Javascript, programming, Ruby)

I must have been dozing off while reading his latest blog post the first time. Steve Yegge, formerly stealing thunder by writing a Ruby on Rails clone in JavaScript called Rhino on Rails, is now adding his touch to Emacs:

I should also mention I've been working on an Ecma-262 compliant JavaScript interpreter in Emacs-Lisp...

The short synopsis is that I'm building a complete JavaScript environment in Emacs-Lisp, with two goals: (1) create a world-class JavaScript IDE for Emacs, and (2) permit writing Emacs extensions in JavaScript, since (2a) people aren't exactly flocking to elisp, and (2b) JavaScript turns out to be a better language, now that I know them both in excruciating detail. Emacs is a great environment that needs a better extension language, and JavaScript seems well suited to navigate the popularity-vs.-elegance tightrope I'm faced with.

That's the elevator pitch: puts people to sleep in 20 seconds, guaranteed.

No, Mr. Yegge of Google and Effective Emacs fame, you have got me excited! :^)

I hate to say it, but despite the countless of hours I have been tweaking with it, Emacs Lisp is not a production language (though it must be really stable to be on version "22" (really though its version 1.22 but they dropped the 1 decades ago)). It sure doesn't have a great library situation. Then again, this infurates me because I thought Emacs Lisp "higher on the totem pole" than JavaScript, because of its macros and Common Lisp as a close relative.

JavaScript must be the world's most run language, though, because it is the basis for client-side interactivity in all major Internet browsers applications. It is Prototype-based language like Self, Lua (not just a scripting language in World of Warcraft, of course) and Io. JavaScript also lives as the Firefox extension language and as Windows Scripting engine JScript and countless other things. JavaScript allows you to flexibly model with object-orientation, but I don't see how this lets you extend the base language like Lisp macros. I mean, who wouldn't want the ability to redefine what "is" is?

;; Emacs Lisp
(flet ((is (&rest args) (what-I-define-is-is args)))
(what-was-the-question-again))

Since Yegge is only devoting 3 hours of time and will probably be able to release something in a year from now, I'll have time to bone up on more JavaScript and maybe I'll learn that I can rewrite "is" in Javascript and mean what I say.

// JavaScript
function (the_question) {
var is_original = is;
var is = what_I_define_is_is( arguments );
return the_question( arguments );
}(what_was_the_question_again);


Unfortunately this is the best I could come up with and it still doesn't do what I mean. :-/ Or is it Microsoft Windows Script Host 5.6 is unreliable? :-( Maybe I need this?

But you know what, there are already modules that allows you to write Emacs Lisp extensions in another language. For Ruby, there's el4r or EmacsLisp For Ruby. It's not as ambitious as Yegge though, because he's shooting for a JavaScript to Emacs Lisp byte code emitter and a IDE. I myself am not exactly writing Emacs stuff in Ruby though, despite my rabid fanboyism. :-(

Labels: , , , ,