[vworld-tech] Embedding JavaScript

Bruce Mitchener bruce at cubik.org
Fri Jan 23 00:17:54 PST 2004


Brian Hook wrote:
> Mike Shaver wrote:
>>We should probably take more detailed JS-doc/impl/embedding
>>questions off-list, if you decide to go farther.  (I won't be
>>personally offended or anything if you don't go with Spidermonkey,
>>it just sounded like you might be avoiding something that could
>>work well for you.)
> 
> Well, unless Bruce objects, I would think JS embedding is actually the 
> kind of thing that a lot of people here would be interested in.

I wouldn't object at all.  I'm interested myself in embedding the JS 
engine, both the SpiderMonkey and Rhino.

In Nebula, we have a kernel that is written in fairly conservative C++ 
and it presents a fairly lightweight object system that can be exposed 
to scripting languages in a fairly generic way.  We already support TCL, 
Python, and Lua.  We've got partial support for Ruby, Java, the .NET 
family.  I'd like to personally see JavaScript join that list, 
especially as I'm thinking about using the Nebula kernel as part of a 
server and I like the security-oriented features of JavaScript.

(I'd like to use E (http://www.erights.org/), but the performance just 
isn't there at all yet.)

I personally don't mind highly detailed discussions of a given subject 
for a brief period of time if it is covering info that isn't widely 
available elsewhere.  Having one of experts in working with SpiderMonkey 
provide some advice on using it in a MUD could be a good thing.

It sounds to me like there are a number of things that could be touched 
upon in a discussion of JS embedding for MUDs:

    * Watchdog for preventing infinite loops.
    * Any other resource starvation prevention mechanisms.
    * Support for threading, continuations, other means of
      multitasking.
    * Impact of GC on a server app, and ways to minimize that impact.
    * Security principals: What are they? How do they work? What
      do they really provide and what types of security models
      are they useful for?
    * The joys of XPConnect: Simpler than SWIG, Boost::Python and
      most other binding systems!
    * I don't know what else, but I'm sure someone else has more
      ideas.

Some of these are things that JavaScript *has* to get right due to 
running in a browser, but that other languages just don't support, but 
are required for our types of applications.

One of these days soon, I'll write up a post about why I no longer think 
Python is a great choice for use in a server app for vworlds now that 
I've written a fair bit of code using Python (but not for vworlds).

> Like I said, if someone is being fairly conservative, given the 
> information available, JS isn't much of a candidate if you're 
> concerned about performance, either because existing data is out of 
> date, inaccurate or non-existent.  I'm not close minded about it, but 
> when looking for docs on Ruby, Python or Lua they are far more 
> abundant (at least when it comes to embedding, not on the languages 
> themselves).

The docs on embedding JavaScript seem pretty decent on Mozilla.org. 
What I find missing is what I find to also be missing from other 
language embedding docs .. the tips and tricks for getting good/high 
performance and good patterns to follow.

  - Bruce



More information about the vworld-tech mailing list