Building DSLs in VS

Last night, after the Turing Lecture, we hosted a FlashBoF on “DSL’s in Visual Studio”. Stuart answered a bunch of questions and gave a much more detailed demonstration of the new DSL Toolkit than we could show during the keynote. Here’s what I learned from the session:

  • Models are stored in XML files. The language designer outputs an object model and will eventually also output an XSD. For example, here’s a screenshot of the language designer from the DSL Toolkit we’re releasing. Inside the designer, I’ve got a sample UIP DSL (I hacked this up on my own, this is not exactly the same one we demoed yesterday). As you can see, there’s a PageCollection concept which contains Page concepts that have Name and Kind values. Page concepts also has a collection of Transfer concepts, which in turn have Label values. Generating an object model makes it easier to write tools that manipulate models. Typically, I’m anti-XML-Serialization but in this case – where we have a relative simple XSD – it works fine. I could also manipulate the model by accessing the underlying XML if I want to.
  • Code generation uses templates and looks a lot like CodeSmith or old-school ASP. You interleave the static elements of the generated code with blocks of code that access the model (via the object model described above) and generate the dynamic model-specific elements of the code. So I’m guessing that people using the codegen tools like CodeSmith will feel right at home with this toolkit.
  • In the current builds (which is to say later than the build that we’re releasing first – the first build doesn’t include any of the code generation support) we’re generating a single code file from a model. Eventually we’ll be able to manipulate multiple files from a single model. This is similar to how the Class Diagram works – add a new class onto the diagram and a new file gets added to the project, delete the class from the diagram and the file gets removed from the solution.
  • Not all models are used to generate code. For example, in VSTS the Logical Data Center and Virtual Deployment models don’t generate code. They are useful  because I can use them to validate the Distributed System Model which does generate code.
  • Someone asked about the implications of code coverage, profiling and test-driven development on a DSL-based process. Frankly, I don’t know but it certainly got me thinking. The general consensus was that we’re still in the bootstrap phase of making DSL-based development a reality and these are issues we’ll have to deal with as we move forward.

OOPSLA Day 1

This morning was Rick Rashid’s keynote with “the big announcement“: a framework and tools for developing Domain Specific Languages in VSTS. Essentially, this is a toolkit for building your own modeling tools on top of the infrastructure that powers the VSTS Distributed System Designers (aka WhiteHorse). Personally, I think this is pretty exciting stuff and I can’t wait to play with it more in the coming months.

As part of the announcement, they demoed the toolkit with a DSL for programming the flow of pages in a web application. Typically, you would use a framework like User Interface Process for this. However, the UIP comes with 130 pages of documentation and a variety of classes and configuration settings. By building a DSL on top of the framework, we can make the developers significantly more productive. I’ve posted a screen shot of the designer – it’s essentially a box-and-stick modeling environment – boxes are pages and sticks are transitions. Dragging a new page onto the design surface from the toolbar generates a new web page in the solution. Dragging a transition onto the design surface changes the config file. That’s much more productive than mucking around in source and config files to accomplish the same task.

Of course, the standard question when we announce stuff like this is “when can I get my hands on it?” We’re going to release a tech preview version of the DSL Toolkit “real soon now”. You’ll be able to download it from the newly minted VSTS Workshop page. I hear that this project, now that it’s public, is going to be very transparent to the community, so keep an eye out for more info (of course, I’ll blog it when the toolkit is released). Honestly, the version we’re shipping “real soon” is much rougher than what we previewed in the keynote this morning, but we’ll be updating it periodically as it marches towards release.

I’ve had several good conversations in the booth with people wanting more info about VSTS and the DSL toolkit as well as Software Factories in general. As is typical, I learn as much as I teach in these sorts of discussions. For example, I met Gan Deng from Vanderbilt who showed me GME – the Generic Modeling Environment – which is DSL modeling environment similar conceptually to what we announced today for VSTS. Not sure when I’m going to get to play with it, but it’s nice to see academia support for DSLs.

The only downer is that some of the OOPSLA crowd was put-off by a product demo during the keynote. Stuart described it as a “commercial break”. Several people gave me “brutal feedback” that brazen marketing displays like product demos don’t work in OOPSLA keynotes. But others thought it was cool. Good to keep in mind for next year.

Update: Alan Kay, in his Turing Award Lecture, made a joke about about our product announcement this morning and everyone laughed, including me.

Update 2: After making a joke about our morning’s product demo (and several other assorted jabs), Alan Kay ended his Turing Award Lecture with…wait for it…a product demo. Two product demos, actually. Squeak is educational programming environment, based on Smalltalk. It is freely downloadable and has an associated community and wiki. Alan did a simple little demo where he drew a car and a steering wheel and was able to steer the car as it moved by rotating the steering wheel. Cool. Alan’s other demo, Croquet is a “massively multi-user virtual learning environment” which is built on top of Squeak. While I liked Squeak, I don’t know many people who spend significant time in a virtual 3D space who aren’t gaming. Frankly, Croquet doesn’t seem particularly practical or useful – check out this screenshot of document collaboration in Croquet. In this example, the 3D space is more of a distraction than an enabler. The only place Croquet seems useful to me is for dynamic 3D simulations, such as this screenshot demonstrating the Coriolis effect.

OOPSLA Welcome Reception

I called it an early night yesterday (which explains why I’m blogging this today instead of last night) but I did go to the OOPSLA welcome reception. Ran into Martin again who pointed me in Gregor’s direction. Gregor presented at TechEd last year and was one of the top five speakers in the architecture track so we chatted about doing it again at next year’s TechEd. (I also got a chance to meet EIP’s co-author Bobby Woolf). Then Martin introduced several other attendees:

We all stood around chatting for a good while. I learned quite a bit and now have to add a few books to my very long reading list. I hadn’t realized that SourceForge is a product in addition to being an OSS code repository. Actually, their aren’t exactly the same – for example SF.net is built on PHP/Perl/Python while SF Enterprise Edition is built on J2EE. As we all started to drift off, Mark mentioned that he appreciated talking with me since didn’t always talk in “glowing terms” about MSFT. Hey, we do a lot right, but that means there’s always areas we can improve on and I always err on the side of honesty and transparency.

OOPSLA Day 0

Day 0 is almost done. Like yesterday, it’s been quiet, but the foot traffic by the booth is improving. I missed the afternoon of the DSL Tutorial tracking down a shipment of JOURNALs that we are handing out at the conference. Martin Fowler stopped by to say hi and we chatted a while about the Architecture Advisory Board. He missed the meeting a couple weeks ago because of a communication screwup (i.e. I didn’t call him) but he’s looking forward to working with us going forward. Some one ribbed him for sitting in the Microsoft booth, so he pulled out his PowerBook (or maybe it was an iBook). I told him that since he like UNIX so much, we should install Services for UNIX on his Windows laptop. 😄

This is a very different crowd from TechEd – not better or worse, just different. Very heavy academic presence. I got a very interesting code visualization demo from an MIT grad student. Flipping thru the conference program, the vast majority of the speakers are from universities. The majority of the remaining speakers are from IBM and to a lesser extent Sun. There’s a small Microsoft presence among the speakers – primarily related to Software Factories. It’s interesting, however, that three of the six of the invited speakers this year are from Microsoft.

By Request: My Response To Booch’s Doubts

Mac asked me to respond to Booch’s doubts about DSLs in his blog. This is at least the second time Booch expressed his skepticism about DSLs, having also done so back in May. The upshot of Booch’s argument is that the semantics across all stakeholder viewpoints must be common.

“There is no doubt that different domains and different stakeholders are best served by visualizations that best speak their language…but there is tremendous value in having a common underlying semantic model for all such stakeholders. Additionally, the UML standard permits different visualizations, so if one follows the path of pure DSLs, you essentially end up having to recreate the UML itself again, which seems a bit silly given the tens of thousand of person-hours already invested in creating the UML as an open, public standard.” (Grady Booch, Expansion of the UML, May 21st 2004)

“[W]hile I agree that development is a team sport and that multiple stakeholders must collaborate in weaving together their diverse, interdependent views, one still needs to have a common semantic basis for all those languages. If you accept that not unreasonable position, you will end up covering the identical semantic ground as has the UML – albeit in an open manner, quite unlike Microsoft’s historical record.” (Grady Booch, Domain-specific Languages, Oct 25th, 2004)

Stuart responded to this argument back in May:

“[Booch] seems to imply that a domain specific-language is just about having a different graphical notation – that the semantics that underpin different DSLs is in fact the same – only the notation changes…[W]hat if the semantic model excludes the concepts that the stakeholders actually want to express?…Surprise, surprise, there are differences from one domain to another, from one organization to another. Far from there being a common semantics, there are significant and actual differences between the interpretations of models being taken.” (Stuart Kent, Domain Specific Modelling. Is UML really the best tool for the job?, May 26th, 2004)

In other words, Booch’s argument against DSL’s falls apart if we don’t have common semantics across all phases of the system’s lifecycle. And frankly, we don’t. Furthermore, Booch offers no explanation as to why you need a common semantic model across all the stakeholders, instead choosing to call it a “not unreasonable position”. Sorry, but I’m not ready to accept the need for a common semantic model as an axiom. I will accept that you need traceability between viewpoints, but I think that is more readily achievable by precise transformations between viewpoints than by a common semantic model of all stakeholder viewpoints.

Common semantic model starts to sound too much like “monolith” as far as I’m concerned. UML 2 addresses a subset of the stakeholder’s viewpoints and many people consider it unusable. After last year’s OOPSLA, Fowler commented “Even on the MDA panel at OOPSLA, the pro-MDA speakers based their assumptions on the fact that they would be using a simplified subset of UML”. If we can’t get a single usable semantic model across UML 2, how are we going to have a single usable semantic model across all the stakeholder viewpoints? Booch paints a pretty rosy picture of UML , but I think the reality of UML is much less attractive, certainly according to the customers I’ve spoken to.