S5 will allow us to finally implement several language interfaces to VOS, including scripting languages.

The VOS scripting subsystem has a simple charter: allowing parts of your application to be written in a scripting language. The primary target languages, at the moment, are Python and (maybe) JavaScript.

Some envisioned uses for it:

  1. Web-style scripting. The "server" side in an application has scripts stored in properties, and clients are expected to execute them. In the case of VR, the "server" would be the sector, and the "clients" would be Ter'angreal.
  2. Multi-language programming. Some tasks are just easier to do in Python or JavaScript or whatever. You may write these parts of your app in those languages, and hook them in.

  3. User scripting. You leave hooks in your application, and allow the user to write scripts to handle certain events. Probably the best example of this is any modern IRC client.

In a complex application, we would expect all three of them to be used; for example, most Gecko browsers do all three -- JavaScript was originally designed for #1, but now with XUL and extensions, more and more pieces are written on it. Extensions are easy enough to write to be considered user scripting, but if you want even easier, there's greasemonkey.

The API is still very much in flux, but here's the basic idea:

  • An application controls which scripting languages it supports by attaching site extensions. PythonScripting, JSScripting extensions exist atm. The site extension is the primary API entry point. (There will be a function at some point in the near future to check a site for an extension that does scripting for a particular language, and return it if present.)

  • A Script object represents an individual piece of runnable code. It might be loaded from a string, from a file, or provided by scripting code itself as a callback.
  • Script objects are compiled to memory, if the target language supports that. (Both Python and mozjs do; I doubt we would want to support a language that doesn't.)
  • Code in scripts has access to a more or less limited VOS API; basically, it behaves more or less like a remote site, so you can manipulate objects (subject to ACLs permitting), but not for example attach or remove site extensions, or shut the application down. If you want to expose a part of your application to scripts, you don't need to deal with any new API; just expose it through VOS, set the proper ACLs, and scripts will see it.
  • Scripts can be stored in properties; probably a new property metaobject. Such properties can be "executed", which runs the script on the local site (regardless of whether the property is remote).

  • Scripts can be bound to handle a message for your object.

Roadmap

VOS 0.24

We should have JSScripting and PythonScripting extensions.

The JS API should be feature-complete and serve as reference implementation.

The Python API could be feature-complete, or it could be read-only as it is now.

Scripts should be loadable from files, strings, or provided as callbacks, for both languages.

C++ code should be able to easily run scripts.

Script properties and message handlers probably won't make it for this release.

C++ code should be able to add new functions to either language's global namespace.

VOS 0.25

C++ API stabilizes.

Python API should be brought up to pair with JS.

Script properties and message handlers should exist.

Development

The scripting subsystem is being written by LaloMartins, in a bzr branch that may be seen here: http://interreality.org/~lalo/bzr/vos-scripting/

Scripting Languages to Support

  • Python
  • Javascript
  • Ruby
  • Lua
  • Microsoft languages?
  • Actionscript plus flash graphics API wrapper?
  • Perl?
  • Lisp/Scheme?
  • Guile?
  • Secondlife script language, plus API wrapper library?


CategoryWorkInProgress

VosScripting (last edited 2008-01-11 20:54:16 by ReedHedges)