Introducing sisula

What in the world is sisula? Sisula stands for ‘simple substitution language’ and it is the key to supporting other databases in our modeling tool. Up until now, the tool was using XSLT to transform XML to SQL. But as it turns out, there are very few people who are fluent in both languages. In that respect, using XSLT was a bad design choice. It also becomes verbose, to say the least, and the code looks quite far from the end result.

So, what we are doing right now is moving towards a template language, in which you write SQL code with some variable names in it. It looks very much like the end result, meaning you only need to have very basic programming skills on top of your SQL expertise in order to write templates. We believe that we will get quicker adoption for other databases using this.

Sisulas are actually a family of languages, and we created a flavor suitable for producing SQL, in which the template code is substituted to JavaScript and evaluated to get the end result. You could say that a sisula is a language in which you introduce a simplification or notation that gets substituted to another language using regular expression replacements. Below is what sisula code looks like, with the template parts delimited by tilde signs.

We also wanted a simple way to access the different parts of a model in sisula. Instead of using the XML, and access it using either XPath notation or through DOM traversal, we decided to expose a JSON-compatible object. That way you can use regular object notation to access the parts, which is more familiar and natural. Below is the JSON description of the schema object used in the template above.

Finally, keeping all code together in a single file, as it was previously, turns out to be somewhat limiting as well. By instead having small templates that encapsulate specific pieces of SQL, it makes it much easier for anyone to insert custom templates in between existing ones, or to leave out certain templates altogether. The example above is contained in its own file: CreateKnots.js. Templates are referenced from a directive, that keeps the process together and lists all the template files that should be processed and in which order.

Our Sisulator (some 100 lines of JavaScript code) does all the work, first converting the XML representation of the model to a JSON object, reads the directive, processes each template file in order, substitutes all template code to JavaScript, evaluates the code, and returns the resulting SQL code. Once done, the example given above becomes the SQL below and similarly for all the other knots in your model.

While the Sisulator is in place, we still haven’t ported the old SQL generation to sisula. We expect to have this done before august, and at the same time add concurrent-temporal generation to the tool.

Published by

Lars Rönnbäck

Co-developer of the Anchor Modeling technique. Programmer of the online modeling tool. Site maintainer. Presenter and trainer.

One thought on “Introducing sisula”

Leave a Reply

Your email address will not be published. Required fields are marked *