Tuesday, October 10, 2006

JAOO - 'DSL implementation at compile-time via syntax extension'

This was the first session I attended on the DSL track, which after concurrency is the thing which most interests me at the moment. As before just some comments and observations on the session, if you want more detail start here. This session was presented by Laurence Tratt who told us about a technique for building DSL's which are compiled at compile time, as opposed to being interpreted at runtime. He's built a language which demonstrates these concepts and this has been used in some real commercial projects - something which always gets my attention.

Laurence started by talking a little bit on our approach to parsing languages, we basically use algorithms from 30 years ago, better approaches have been found since but we seem to have stuck with the older ones due to perceived performance issues. In his work Laurence has used the Earley Parser which apparently makes things a lot easier - having written some simple compilers I'd certainly appreciate something easier and simpler.

The approach his converge language takes to a DSL is to embed the DSL into the rest of the code, effectively as a Macro. (Hmmm, LISP?) Converge uses the same parser for the DSL's as the main language, so all the converge syntax and features are available for the DSL as well. It also means we need to do much less work to implement a DSL. Laurence showed some real code, one key feature is that the macros generate converge sourcecode (at compile time) which in turn is compiled along with the rest of the program. Features of the macro's allow this code to easily interact with the rest of the program. Having tried to acheive something similar with c# 2.0, where I ended up having to generate byte code, I can see how much easier being able to generate sourcecode is.

Overall I really liked this presentation, I've not really done it justice here, I'm determined to see if something similar could be done in c# 3.0.

0 Comments:

Post a Comment

<< Home