-
Notifications
You must be signed in to change notification settings - Fork 0
jtlc and JXL Rationale
This project grew up from an effort to create an MVC architecture for Web applications around hierarchical, document-oriented data models shared between the client-side and the server-side layers. Early on, a disconnect was observed between the data representation that naturally expresses the relationships between the objects of a data model and the requirements to the data structure imposed by the visualization and UI components: especially in the case of multiple views of the same data, the two are often hard to reconcile. Even with a single view, letting the UI drive the data model design violates separation of concerns.
An obvious direct approach — writing increasingly complex Javascript expressions and loops to collect relevant data from the model as part of the view code — has 2 major disadvantages:
- It is the code that has to be maintained, and it is impacted by every change in either the data model or the view so the simpler it is the better;
- If a template engine is used to render HTML, such code becomes a clumsy interface between two more expressive entities.
In short, a more explicit and compact declarative description — along the lines of XSLT — was desired to express data re-shaping operations.
- The excellent JSON Query library provides XQuery-like functionality over Javascript data structures. It was evaluated and found to be falling short of the target from the standpoint of shaping the resulting data, In fact, JXL may be considered to build on top of JSON Query as the next layer of functionality;
- The JSLT library by Rik Arends. A very interesting contender that was, in the end, discarded, because the JSON Query syntax and capabilities were considered superiour.
Two linked but conceptually independent entities have grown from this project:
- The jtlc (Javascript Template Language Compiler) — a framework for generating optimized Javascript code from an abstract syntax tree with semantics based on the dataflow processing model. The minimal amount of node semantics that the framework provides directly can be redefined and customized; the rest comes from an extensible collection of node classes or tags.
- The JXL (JSON Transformation Language) — a basic collection of tags that provides a comprehensive set of capabilities for querying and re-shaping JSON data (i.e. hierarchical collections of Javascript dictionaries and arrays).