The above demo shows the key advantage that MochaBlox brings to the
web applications developed by LogicBlox. By avoiding server
communication, the particles in the above simulation can be updated at
a full monitor refresh rate. Furthermore, responses to to the
horizontal slider and to the "Run/Pause" button are instantaneous.
Some notable aspects of this project:
I developed a compiler from the company programming language to
JavaScript. The compiler supports full language semantics, including
view maintenance and Statelog-style transactions.
The compiler could compile the entirety of a typical LogicBlox web
application in about one second.
I designed a "ports" extension to the company Datalog
dialect. Ports bridge the gap between two different computational
models: the transactional, state-free semantics of Datalog, and the
event-loop model supported by web browsers.
I developed a novel debugging technique, based on source maps, so that
developers could single-step their Datalog code within a web browser.
The technique is described
in Source
Maps for Non-traditional Source Code.
I integrated the compiler with the company UI framework, so that
developers could describe their UI layout using a YAML
file. Developers could write the name of a MochaBlox port as an
attribute of a UI control such as a text field, and anything typed
into the text field would be forwarded to the designated MochaBlox
port.
out.js:
JavaScript output for the above code.
There is a JavaScript comment in the file for each Datalog rule,
followed by the compiled version of that rule.