Some Seed updates

April 13, 2009

I haven’t blogged much recently, but I put a lot of work in to Seed this weekend and thought I would discuss some of the changes.

New imports system
First I should note that the design of this is pretty much lifted from gjs, and the two implementations should be compatible. I do however think, it’s a very cool system, even if a bit unorthodox.

People who have used Seed would recognize that the two primary methods of importing things are
For importing libraries and native modules and
for importing files.

This however was pretty ridden with problems, notably:

  • Importing GI namespaces had no sort of cache, so multiple files including eachother can’t all import the namespaces they need, one central file would have to import them all and the others rely on that
  • No search path for native modules
  • The including files, was merely evaluating the file in the context which was called, which could create a lot of scope issues, in particular when you have a lot of complex interdependencies in what files need from what.

So the new imports system works like this, and remedies most of these problems. There is a toplevel imports object, which itself has a “gi” property (the object) which handles importing libraries handled by introspection, and has a pretty simple set of semantics, notably the first attempt to access will return the module object for that library, and subsequent attempts will return the same object. You can set to a value to force GI to require that version of the library, so importing a library might now look like. = "0.8";
Clutter =;
Gtk =;

The exciting part is really the handling of native modules and files, there is an imports.searchPath property which is set to an array of directories used to search for files/modules. An attempt to access will now look for “name.*” in search path, and behave as follows:

  • If the found file is a native module, import it and return the module object
  • If the found file is a regular file, attempt to evaluate it as a JavaScript file in a new context, and return the global object for that context. Unless the file has already been imported, then return the global object from the last import
  • If the found file is a folder, return a special object which works like the “imports” object for that folder

So, importing files is now much nicer, i.e.
BrowserView = imports.browser.BrowserView
and then you could access the toplevel contents of the file “browser/BrowserView.js”, through the BrowserView object. This has a lot of advantages, notably any file that needs anything in BrowserView can do this, without having to worry about scope, or overlap with other files that might include it.

All in all I think this is a really big improvement to the maintainability of large programs, and makes it feel like there is much more of a real module system. In addition this should make it pretty possible to port GNOME Shell to Seed, and this is something I will be looking in to.

OS module
There are a lot of low level unix functions not provided by GLib, which might still be useful under Seed, and to that account I’ve taken to reimplementing a large subset of the python “os” module, attempting to preserve semantics where it makes sense, for familiarity purposes. This should be nice for increasing the scope of where Seed is useful, but it’s really boring work…which should hopefully be finished over the next week or so.

The canvas module has a pretty large subset of canvas implemented now, and properly handles saving/restoring state. I’m hoping to implement gradients and a few other missing things within the next few days.

I am still working on DBus bindings, this is slow work, and will be done eventually :P. A lot of work got done recently though, and hopefully should be ready to go in GIT soon.

New Release
After these changes, the goal is to put out a release within the next few days, as soon as someone can find time to update documentation, all the examples, etc…

On top of this there have been all the usual bugfixes, optimizations, and small features, so I definitely encourage anyone interested and using the last release to start investigating GIT. There will be a lot more reorganization of the builtin functions (on the Seed global object) over the next few days, with the goal of eliminating (or eliminating for most code) the requirement of this object, and I suppose this will break most code out there, but I think it’s definitely necessary changes for presenting a more “mature” interface in a sense.

2 Responses to “Some Seed updates”

  1. Polurt Says:

    Good news :)

    Will try to run from git now.

  2. rektide Says:

    You really really need to join up with the Server-JS group so you arent just adopting your own conventions, but working with the other people building javascript runtimes. and

    In particular, your talk of import made me think of the existing proposal for loading files:

    Your idea of introducing namespaces seems like the sort of thing ServerJS needs to start considering, and fast.

Comments are closed.