Hitchhiker's Guide to Software Architecture and Everything Else - by Michael Stal

Thursday, June 22, 2006

The Arrival of Language Integrated DSLs

As I introduced it in my last posting about Lisp and LINQ, I'd like to discuss an increasingly important topic with a little bit more details. I spoke about Language Integrated DSLs (LIDs) which basically combines programming languages with DSLs. What does this mean? Let me introduce an example for motivation. As you know the basic problem of accessing a database from Java or C# is impedance mismatch. Either we choose a programming language perspective using an Object Relational Mapping thus being unable to leverage some strengths of the database system. Or we may choose a relational database perspective instead where we get all the power of relational algebra but don't integrate with the Java object model. You can see the same problem again and again, for example when dealing with XML and Java or C#. The idea of LIDs is to integrate a sublanguage to your programming language. For example Microsoft LINQ (Language Integrated Query) allows to use select statements within C# programs to access the database. This is integrated in the languages (C#, VB). Don't mix this with previous approaches that were just relying on preprocessing or adaptation such as SQLJ or JDBC. The LID LINQ is integrated into the programming language C#. Note, that this has some proximity to other concepts such as multi-paradigm programming (read Cope's book for details - Cope stands for Jim Coplien :-). It is also an approach that is heavily used in XML. where Schemas may be modularized and integrated. For example, SOAP and WSDL use XSD as basis for type definitions and declarations. To be honest meta annotations are also a kind of additional language on top of your programming language which means that the integration of languages might happen in different ways. Future programming languages could become extensible sets of core language features that might be integrated with(in) sub languages (LIDs). For example, a domain specific language could be part of your favourite programming language. Note, that this approach does not remove the need for higher level domain specific languages. These are still very important, as for example in Model-Driven Software Development) . From my viewpoint, AOP approaches are also candidates where LIDs might be helpful. An aspect or related set of aspects can be considered as a language. Tools such as AspectJ help to formalize the language and integrate it with Java. The former HyperJ was also heading into this direction. Another advantage of these kinds of modularized languages is the fact that you don't need to bloat languages or libraries any more to get all those important features into the programmer's toolset. Instead, configure your core language with all the sub languages you require for your concrete problem. Language Integration might become a powerful tool for the future. I am really interested what others think.

4 Comments:

  • Why would this DSL support still have to arrive? Isn't it already there in Ruby, Scheme or Lisp?

    By Blogger Stefan Tilkov, at 2:55 PM  

  • I think that the main difference with C# now is that this is going to happen in a mainstream development environment.
    It is also the possibility of finally integreating SQL and object oriented languages.
    I already experimented a bit of this with the Query by example support from Hibernate, but, after looking at the Concept paper from M$ related to this integration of both "SQL" and XML I think they are very very close to getting it right for the first time.

    This of course in mainstream programming languages, although in C++ (a mainstream language) with macros and template metaprogramming we were very close. The problem was one of tooling...

    Oh, about this, I wonder how to debug a beasty SQL query will be in M$ dev studio... Probably thats were this will begin hiting the wall ;-)

    By Blogger euluis, at 11:01 PM  

  • I think, euluis brought up the important point. It is now happening to mainstream languages. But of course, as Stefan mentioned, Ruby, Scheme and Lisp are already strong with respect to supporting different "paradigms". But they don't follow the Open/close principle. What I would expect that languages are more opened up to integrate DSLs, even by "3rd parties". AspectJ is an example of how to integrate a language into another language.

    By Blogger Michael, at 11:45 PM  

  • Hi Michael,

    I have put up a little post about the (possible) evolution of future programming languages here: http://geekswithblogs.net/akraus1/archive/2006/06/23/82859.aspx

    Yours,
    Alois Kraus

    By Anonymous Anonymous, at 10:29 PM  

Post a Comment

<< Home