Wednesday, July 29, 2009

Another step towards Stockholm

[Ed. note: click on an image to get an enlarged view. Code has been captured as images due to strange layout behavior.]

Today, i committed Stockholm's first version of the SQL persistence layer based on Stefan Szeiger's scala-query to github.

Let's take a look at how this all fits together by way of a familiar example. Our old friend, the lambda calculus, is a paradigmatic DSL -- the mother of all DSL's, with that peculiar kind of specificity that makes it generic again. Here's the syntax of a version of the lambda calculus in the input language for Stockholm.



From this language we generate
  • a parser for a concrete language that we can type in at the keyboard;
  • latex'ed and html'd versions of documentation of the concrete syntax;
  • an abstract syntax that doubles as a data model, expressed as Java objects that are accessible from Scala;
  • a persistence mapping for the data model;
  • a lift-based web wrapper around a minimalist REPL that simply reads the concrete syntax and pretty prints the abstract syntax tree corresponding to the input expression
  • as well as links to pages for the documentation on the lift site map;
  • a RabbitMQ transport for JSON serialized versions of the data model.
Above we see a screenshot of the first page of the generated site (after the login page); and below we have shot of the REPL page



The form is backed by the following scala code which determines what the user has asked to do with the source (parse it, evaluate it, type it or send a JSON representation of it to a queue).



Parsing an abstraction like the one in the top window will result in an instance of the Java object that represents Abstractions



Instances of this object can be stored and retrieved via the scala-query mapping for the Abstraction object.



These bits and bobs enable the sorts of communication flows depicted in this diagram.


The point, of course, is that all of this infrastructure is completely generated. Instead of our old standby, the lambda calculus, we could have put in a description of patient records in a health care information processing system.

4 comments:

Unknown said...

Pretty amazing stuff. My head spins. :-)
/Jonas

Unknown said...

Pretty amazing stuff. My head spins. :-)
/Jonas

Andy Czerwonka said...

Interesting.... how does this all fit in with the new Record framework?

Also, what tool did you use to create this graphic?

http://3.bp.blogspot.com/_MpnB66rjq_o/SnEdTQzi0uI/AAAAAAAAAEk/FDpFjDDIOS4/s1600-h/Stockholm.jpg

leithaus said...

Wow... i didn't know anyone was actually reading this stuff. The graphic was created by Omnigraffle.