08 October 2007

EcmaScript, IF, and DSLs

Since I’ve been programming so much in EcmaScript (a.k.a. Javascript) at work, I decided to install the stand-alone version of Spidermonkey at home. That’s the EcmaScript implementation from Firefox. Partly because I’m interested in being able to write web applications that use the same language on both the browser-side and the server-side.

Of course, there are a few server-side EcmaScript solutions out there, but I’m used to rolling my own light-weight version when investigating such things.

I didn’t want to jump right into that, however, so I tried to come up with an idea for a command-line program I could start with. Spidermonkey comes with a command-line interpreter, but it is very minimal. Hardly more than readline and print.

So, I thought of text adventures (a.k.a. interactive fiction). I had the basics of Cloak of Darkness mocked up PDQ. It went faster and farther than I think any of my other attempts at such a program has gone in any language. My opinion of the EcmaScript is continuing to increase. I began to think I should break out some of my old text adventure ideas.

The thing is, though, I’d have to make some significant enhancements to Spidermonkey’s command-line interpreter to really make it practical for IF. It would make a lot more sense to just use browser-based EcmaScript (instead of command-line) or to use Inform, so that people besides just me could actually play it.

Inform is a DSL (domain specific language) for interactive fiction. That’s fancy computer geek jargon for a language specialized for a specific purpose.

C, C++, Java (no relation to Javascript), Perl, Python, Ruby, Lisp, and Scheme are general-purpose programming languages. They can be used to build programs for a wide range of applications. (Although, certainly, some are better for some applications than others.)

HTML and Postscript are domain specific languages. (Incidentally, HTML is not a programming language, but Postscript is.)

EcmaScript isn’t really a domain specific language, but as it is most widely and most easily used within web browsers, it often tends to be one in practice.

I’m all for DSLs, but the problem I have with most of them is that they’re wholly new languages. Ideally, a DSL—unless really simple—should be an extension or a subset of an existing language. This is the resistance I have towards using Inform.

The Lisp and Scheme advocates like to point out how they often extend their languages to create DSLs within them, which I’m finding to be a very compelling argument.

No comments: