Saturday, July 7, 2007

Sciter, TiScript, DyBase and JSON

If you have ever looked at XUL for Mozilla, you owe it to yourself to look at an alternative way of declaring a UI with JavaScript.
TiScript is an extended-JavaScript with a few twists and it works with DyBase to provide scripting and persistence for Sciter.
Sciter is from Terra Informatica, whom you may know for BlockNote or their SqlLite wrapper.

What Sciter offers is an alternative to JavaScript+DOM. Instead of loading the DOM for an HTML page, the strategy is to use TiScript with a few extensions to CSS.

Sciter offers web developers 8 DOM and Window classes:
  • Element - DOM element. All HTML elements including the document root, frame, inputs, etc. are elements in Sciter.
  • Attributes - a collection of named attributes of any html element.
  • Style - a collection of style attributes applied to any element.
  • Image - bitmap image objects on which you can draw using Graphics methods
  • Graphics - an object wrapper for drawing primitives for drawing on any Element or Image
  • View - represents Sciter window (the main Sciter window and Dialog are views)
  • Event - represents the current UI event.
  • Sciter - a global object holding Sciter application specific methods.

Top level windows are represented by View objects in Sciter. Both the main window of the Sciter.exe application and the client area of the X-Sciter.dll sandbox window are views. Dialog windows also have their associated views.

Each view has a root property which is the root element of the loaded document. The root element in Sciter is the <HTML> element of the loaded document and there is no dedicated Document class because in Sciter the Document is an element tree composed of an element and its children.

Frames and framesets are also ordinary DOM elements. Each has a single child element: the root element of the loaded document. If the document is loaded into a frame, the parent property of the root element of the document will refer to that containing frame element.

These simplifications are intended to make up for inherent weaknesses in how CSS+Javascript is used in web layout to complement simple HTML.

This interests me while I am looking at the separation of concerns which is attempted by Mozilla with XUL for Firefox and for other XPCOM applications outside the browser which use the XPFE (Cross-platform front-end) framework. Sciter+TiScript+JSON is also interesting when contrasted to Rebol/View and the upcoming Liquid-GLayout marriage for Rebol (Rebol does not yet have a cross-platform IDE - which is something else Rebol shares with Oz and Mercury.)

The major change that you will find in TiScript is the use of type to define both classes and modules (namespaces) without the prototype-based emphasis of JavaScript. A class with a this() function has an instance constructor*. In TiScript the prototype field is a reference to a type or is undefined. TiScript also has a nice variant on C# properties to provide set and get accessors for field privacy. Sciter itself uses 'self' to refer to the root object as in self.myFunc()

Corporations in the far east which have used Curl will not want to migrate to XUL+rdf+dtd+css+js and it is hard to imagine ActionScript and Flash as being much more attractive. It would be interesting to know whether TiScript itself would obviate the need for the Google Web Toolkit as a JavaScript nostrum while also streamlining the scripting ( GWT is touted as a remedy for unintended JS closures causing memory leaks under IE - but I should add that GWT does have a fine inexpensive plugin to Eclipse by Instantiations.)

Another point of interest is that TiScript offers JSON persistence through a version of a DyBase library which has been modified to support 'native' TiScript. DyBase is said to have interfaces to PHP, Perl,Python, Rebol and Ruby but I could only find a Smalltalk alpha outside of the home archives of the DyBase author (and none at, CPAN or the Python Cheese Shop and no RubyForge or sourceforge entries; the dybase site at was off-line this weekend.)

Dybase could be as neglected as the database options offered by associative and hierarchical/network databases (MUMPS, DNS and LDAP are hierarchical) in the world of MySql and XBase. And there is Lazysoft, to which there are links at StumbleUpon and AboutUs.

Perhaps if an AltME group opens on DyBase there will be an opportunity to judge its merits across a few languages. Until then I will watch ltu.

* the author of TiScript is the author of Harmonia, an FLTK for the D language.


Andrew Fedoniouk said...

Thanks for the attention to the Sciter, Robert.

About Sciter goals I tried to write here:

Part I.
, Part II., Part III.

andry said...

json is a very interesting language to be used. very good tutorial and can hopefully help me in building json in the application that I created for this lecture. thank you