[MUD-Dev] How much should be offloaded to Scripting?

Kwon J. Ekstrom justice at softhome.net
Wed Feb 18 10:41:43 New Zealand Daylight Time 2004

gbtmud wrote:
> From: Patrick Dughi [mailto:dughi at austin.rr.com]

>> It _could_ save some, but what sort of scripting system did you
>> build where a script needs to be parsed more than one time?  In
>> fact, many scripting systems out there (for example, lua), allow
>> you to externally compile your scripts, which are then executed
>> as simple sets of hard coded instructions nice as you please.  I
>> won't lie and say it's as fast as native code, but it's
>> reasonable enough that you shouldn't worry about processing
>> overhead from parsing.

> Would this performance factor change if you were programming the
> interpreter/compiler for the scripting language in Java?

I don't know about other languages, but Rhino can compile Javascript
into bytecode, so the JVM will run it (almost) as fast as native
java classes.

In one test, a javascript took approx 1/3rd of a second to parse and
execute.  When pre-compiled and executed, the compile time was about
100ms with under 10ms per execution.  Granted, this was an extreme
case... it was a poorly written script... but it does highlight the
potential differences.

  (these tests were on an old worn-out K6II-450... I figure if that
  thing runs it with acceptable performance then the production
  machine should run it great...)

However, I say it really depends on what you're doing.

For my mud where scripts rarely change and the application is
running for long periods of time I pre-compile my javascript.
(Scripts are compiled at first-execution, if a script is modified,
it's compiled version is released and set to null... if it's null at
runtime it gets compiled)

Another project of mine, I use javascript in a similar manor to HTML
to handle validation/etc in a java form.  These scripts generally
have a small lifetime, but there are alot of little statements
attached to handlers on awt components.

In this case, I don't bother to pre-compile them, as this creates
the overhead of keeping track of the pre-compiled scripts/etc.  It
would also create serious latency during form-loads (as you have to
wait for possibly hundreds of scripts to compile).

  Please Note: my mud is a research project... and I keep the
  admin/playerbase small... the other however is production code for
  a work project.

-- Kwon J. Ekstrom
MUD-Dev mailing list
MUD-Dev at kanga.nu

More information about the MUD-Dev mailing list