dotnetpro 08/2009 – Nordische Grammatik: Domänenspezifische Sprachen mit Microsoft Oslo M

Soeben ist der dritte Artikel der DSL-Serie von Markus und mir bei der dotnetpro erschienen.

Bild 11

Abstract: Mehrspaltige Layouts für Webseiten sind komplex und stellen hohe Ansprüche an den Webprogrammierer. Warum nicht eine Sprache entwickeln, die solche Layouts vereinfacht? Mit Oslo M und dem ASP.NET MVC Framework lässt sich so eine Sprache realisieren.

Inhalt

Hauptsächlich dreht sich der Artikel um MGrammar, den Teil der Sprache Microsoft M (Teil von Microsoft Oslo) mit dem andere Sprachen definiert werden können. Zuerst wird die MGrammar (Arbeitstitel) anhand einer simplen “Hello, World”-Sprache erklärt.

Danach erstellen wir eine DSL zur Beschreibung mehrspaltiger Layouts und bringen diese mittels ASP.NET MVC und YAML ans laufen.

Das Beispiel im Artikel basiert auf der Oslo January CTP, der Quelltext für das Oslo May CTP kann aber bei mir angefragt werden.

Beispiel

Typisches dreispaltiges Portal-Layout.

Konkretes Layout - dreispalter

* Die Berechnung der Restbreite stimmt hier nicht. Richtig wäre:

Rest = (75%* Gesamtbreite) –400px

Dies mag aber von CSS-Framework zu CSS-Framework variieren.

DSL zur Beschreibung

Die Syntaxhervorhebung ergibt sich aus der Grammatik und ein wenig Konfiguration.

intellipad - Syntaxhervorhebung

Advertisement

dotnetpro 07/2009 – Turmbau zu Babel – DSLs entwickeln mit Eclipse Xtext

Der zweite Artikel unserer DSL-Serie bei der dotnetpro ist raus. Warum der Artikel Turmbau zu Babel heißt weiß ich nicht 🙂

Bild 2

Abstract: Domänenspezifische Sprachen sind eines der vielen Mittel, um Software zu industrialisieren und vor allem zu automatisieren. Praxisnah zeigt dieser Artikel eine DSL für den Import von Mainframe-Exporten – zum Beispiel, um Daten von einem Mainframe zu importieren und dabei zu konvertieren. Eclipse Xtext leistet beim Erstellen einer passenden DSL hervorragende Dienste.

Autoren: Markus Völter und Lars Corneliussen

Lang.NET and DSL DevCon (Seattle 2009)

I just got back from a good week in Seattle. My plan was to visit the DSL DevCon only, but it turned out that the cheapest option was to stay from Tue, 14th until Sun, 19th. I then had time to visit both Lang.NET and DSL DevCon as well as some friends in the area. Last time in Seattle (ALT.NET Conf) I was occupied with shopping only, but this time I also had a whole day for sightseeing. It was great!

Lang.NET (tweets, videos)

langnet Lang.NET was all about general-purpose languages. The talks were good and I met interesting people. This two tweets from Paul Vick (VB.NET compiler in person) and Amanda Laucher (F# MVP) pretty much sum up, what I felt most of the time:

vick paulvick: I hope someday to be as funny as Gilad or Erik Meijer.

 

panda-vick pandamonial: @paulvick Some day I hope to be as clever :) 

 

I left with a superficial (limited brain capacity) overview over F#, Tcl/tk (Eagle), CodeContracs, JVM internals, Axum and Links.

DSL DevCon (tweets, videos)

fill-your-head DSL DevCon (aka SellsCon) was initiated by Chris Sells. Both conferences were held in the Microsoft Research Building on their Campus in Redmond (close to Seattle).

I don’t yet know what to expect from the DSL hype. People have been doing DSLs for decades, as they did SOA. But who knows which story marketing starts telling about DSLs soon.

Still, I got my head filled up with lots of new useful information. Things I’ll have a closer look on will be Irony, F# and the Intentional Software. I’ll also follow up on all the good connections to super-interesting people. Was also nice to finally meet the Oslo guys Doug Purdy, Don Box, Chris Sells, Jeff Pinkston, Chris Anderson, Paul Vick and David Langworthy in person.

I’ll write follow-up posts about what I learned as soon as I have time for it.

What’s next?

I’m really tuned to see how our profession will evolve. I hope it will change dramatically. We need better processes, better integrated tools, closer communication of intentions and a significant productivity boost. I can’t believe that we will be able to create software so much faster. But, if our software wasn’t so closely tied to platforms and if it was written in a more flexible manner, so I hope, software could at least survive longer. Software is often dead born. That is, were our industry looses so much of it’s productivity.

dotnetpro: Kurzer Rede langer Sinn

Der erste Artikel der DSL-Trilogie bei dotnetpro ist raus 🙂

Titel: Kurze Rede langer Sinn –Domänenspezifische Sprachen in der Softwareentwicklung

Abstract: Mit wenigen Worten viel sagen; das ist das Ziel einer guten domänenspezifischen Sprache. Sie sind in Kundenprojekten
jüngst in Mode gekommen, um fachlichen und technischen Anforderungen besser begegnen zu können.

Ausgabe: dotnetpro 05/2009 (15. April 2009)

Autoren: Lars Corneliussen und Markus Völter

Ja, wirklich:

Bild 10

DotNetMagazin: Domänenspezifische Sprachen und Microsoft Oslo

Abstract: Auf der PDC letzten Herbst hat Microsoft eine neue Plattform vorgestellt: Oslo. Dabei handelt es sich um Frameworks und Tools zur Arbeit mit Modellen und der Erstellung von domänenspezifischen Sprachen. In diesem Artikel möchten wir einen Überblick über Oslo geben, und es in das Umfeld der modellgetriebenen Softwareentwicklung und der DSLs einordnen.

Download: http://www.voelter.de/data/articles/VoelterCorneliussen-OSLO.pdf

Publiziert in: DotNetMagazin Developer Channel, 03/2009

Markus Voelter, Independent/itemis, voelter@acm.org
Lars Corneliussen, itemis, lars.corneliussen@itemis.de

Fowler’s DSL example with MGrammar (Draft!)

I drafted Fowlers state-machine example with MGrammar. While doing so I found a few things I would like to see optimized or find better solutions for.

  • New line handling. I would like to express one required new line, when it is required, but then ignore all the others. Forum discussion.
    I could make new lines part of some tokens and then just interleave other tokens. But I don’t think this would be a nice solution. Any ideas?
  • The blocks events, resetEvents, commands and state+ have to be written in order. It is possible to describe a grammar where unordered blocks would be allowed, but it’s not trivial.
    Ordered and unordered “Lists” of syntaxes, separated somehow should IMHO be supported directly: forum discussion.
  • I wrote the Grammar using Intellipad and the three-pane input/grammar/AST view. It’s great! But I’d like to define the Semantic Model (using MSchema) along with the grammar and directly validate my AST against it: forum discussion.
  • References are not directly supported by MGrammar/MSchema. Forum discussion.
  • Xtext, which is quite comparable to MGrammar has a much more compact syntax. But I haven’t done a more deep comparison yet.
    Sven Efftinge’s Blog: Fowler’s DSL example with Xtext

Still missing:

  • A schema that represents the structure of the AST and validates it using constraints.
  • An adapter to Simple State Machine on CodePlex or a generating a state machine framework using T4.

Would love your feedback…

Grammar definition

module MGrammar.Net.Sample {

  // This is my first try, to parse the state machine
  // dsl syntax proposed by Martin Fowler
  language Statemachine 
  {
    interleave Ignore = " ";
    
    syntax Main = 
        NewLines? e:Block(Events, NameAndCode)
        NewLines+ r:Block(ResetEvents, Name)
        NewLines+ c:Block(Commands, NameAndCode)
        NewLines+ s:List(StateBlock)
        NewLines?
        => Statemachine 
        {
          Events { valuesof(e) },
          ResetEvents { valuesof(r) },
          Commands { valuesof(c) },
          valuesof(s)
        };
        
    // list of syntax "Item" separated by one or more
    // new lines
    syntax List(Item) = n:Item => {n}
        | list:List(Item) NewLines+ n:Item 
            => {valuesof(list), n};
    
    // lists of tokens separated by whitespaces 
    syntax TokenList(Item) = n:Item => {n}
        | list:List(Item) n:Item 
            => {valuesof(list), n};

    // a block consisting of a keyword, new-line-
    // separated "Item"s and end
    syntax Block(Keyword, Item) = Keyword 
            NewLines items:List(Item) 
            NewLines End => {valuesof(items)};
            
    // a word projected as a name
    // grouped into a separate successor
    // for extensibility reasons
    syntax Name = n:Word
        => { Name {n} };
        
    // a word plus a code, separated by spaces
    syntax NameAndCode = n:Word c:Word
        => {Name {n}, Code{c}};
    
    
    // special block and subsyntaxes for states
    syntax StateBlock = State n:Word 
            actions:(NewLines a:Actions => a)?
            NewLines+ items:List(Transition) 
            NewLines+ End 
            => State 
            {
                Name { n }, 
                actions, 
                Transitions { valuesof(items) } 
            };

    syntax Transition = e:Word "=>" s:Word
        => { Event {e}, ToState{s} };
        
    syntax Actions = tActions "{" l:TokenList(Word) "}" 
        => Actions [ valuesof(l) ];
    
    
    // keyword specification for strong formatting
    @{Classification["Keyword"]} final token Events = "events";
    @{Classification["Keyword"]} final token Commands = "commands";
    @{Classification["Keyword"]} final token ResetEvents = "resetEvents";
    @{Classification["Keyword"]} final token State = "state";
    @{Classification["Keyword"]} final token End = "end";
    @{Classification["Keyword"]} final token tActions = "actions";
    
    
    // Some whitespace characters
    token NewLineCharacter 
            = 'u000A'  // New Line
            | 'u000D'  // Carriage Return
            | 'u0085'  // Next Line
            | 'u2028'  // Line Separator
            | 'u2029'; // Paragraph Separator
            
    token NewLines = NewLineCharacter#2..;
         
    token Letter = 'a'..'z' | 'A'..'Z';
    token Digit = '0'..'9';
    token Word = (Letter (Letter | Digit)*);
  }
}

Input Text

events
  doorClosed  D1CL
  drawOpened  D2OP
  lightOn     L1ON
  doorOpened  D1OP
  panelClosed PNCL
end

resetEvents
  doorOpened
end

commands
  unlockPanel PNUL
  lockPanel   PNLK
  lockDoor    D1LK
  unlockDoor  D1UL 
end

state idle
  actions {unlockDoor lockPanel}
  doorClosed => active
end

state active
  drawOpened => waitingForLight
  lightOn    => waitingForDraw
end

state waitingForLight
  lightOn => unlockedPanel
end

state waitingForDraw
  drawOpened => unlockedPanel
end

state unlockedPanel
  actions {unlockPanel lockDoor}
  panelClosed => idle
end

Output AST

Statemachine{
  Events{
    {
      Name{"doorClosed"},
      Code{"D1CL"}
    },
    {
      Name{"drawOpened"},
      Code{"D2OP"}
    },
    {
      Name{"lightOn"},
      Code{"L1ON"}
    },
    {
      Name{"doorOpened"},
      Code{"D1OP"}
    },
    {
      Name{"panelClosed"},
      Code{"PNCL"}
    }
  },
  ResetEvents{
    {
      Name{"doorOpened"}
    }
  },
  Commands{
    {
      Name{"unlockPanel"},
      Code{"PNUL"}
    },
    {
      Name{"lockPanel"},
      Code{"PNLK"}
    },
    {
      Name{"lockDoor"},
      Code{"D1LK"}
    },
    {
      Name{"unlockDoor"},
      Code{"D1UL"}
    }
  },
  State{
    Name{"idle"},
    Actions[
      "unlockDoor",
      "lockPanel"
    ],
    Transitions{
      {
        Event{"doorClosed"},
        ToState{"active"}
      }
    }
  },
  State{
    Name{"active"},
    Transitions{
      {
        Event{"drawOpened"},
        ToState{"waitingForLight"}
      },
      {
        Event{"lightOn"},
        ToState{"waitingForDraw"}
      }
    }
  },
  State{
    Name{"waitingForLight"},
    Transitions{
      {
        Event{"lightOn"},
        ToState{"unlockedPanel"}
      }
    }
  },
  State{
    Name{"waitingForDraw"},
    Transitions{
      {
        Event{"drawOpened"},
        ToState{"unlockedPanel"}
      }
    }
  },
  State{
    Name{"unlockedPanel"},
    Actions[
      "unlockPanel",
      "lockDoor"
    ],
    Transitions{
      {
        Event{"panelClosed"},
        ToState{"idle"}
      }
    }
  }
}

What "Oslo" is and is not (November 2008)

See also: Open Letter to Douglas Purdy: Eclipse, Oslo, and how to invent the future together

The PDC is over, and most contents including the Oslo SDK (without Quadrant) and all PDC Session Videos on channel9. Thanks! But where are we now? If you want a “brief” overview, you should at least have a look at A Lap around “Oslo”.

Jump to “What Oslo definitely is!”

Oslo Resources

What Oslo is not!

I’ll start with correcting some of my former assumptions in DSL Tools, T4, the Software Factories and “Facts” Rumors about Oslo.

Built upon DSL Tools?

No, Oslo (M and Quadrant) is not built upon DSL Tools, T4 and the UML Tooling in Visual Studio 2010. It’s totally apart. The DSL Tools are the here and now, while Oslo still is “Pre-Pre-Pre-Alpha” (Douglas Purdy).

Douglas promised that his team is working tight with the VSTX team in order to bring this together. He mentioned the possibility of using M as the backing metamodel format for the DSL Toolkit. Graphically edited DSLs could then be converted, described in MSchema and stored into the Oslo Repository or MGraph files. Update (12.Nov): Later in his talk “a lap around Oslo” Doug also said his the team is discussing to schematize the DSL Toolkit, and let the graphical DSLs live within Oslo.

A move towards UML/OMG?

No. I don’t think so. Microsoft joined the OMG and they support some UML Diagrams in Visual Studio 2010. But so far this has not to do much with Oslo.

Update (12.Nov): Someone asked about how Oslo relates to XMI and UML. Doug’ promised that they will model the UML-Domain and let the UML Designers in Visual Studio live within Oslo.

Talking of Model-driven Architecture (MDA) it seems that Microsoft avoids this abbreviation. They rather talk about Model-driven Development and Model-driven Applications – I’ll write more on this in a separate post.

A Application/Process Server?

Dublin is announced to be Model-driven, but it is not a part of “Oslo”, but rather related to Windows Azure and IIS. The plan is to host cloud-enabled services both locally on Dublin and in the cloud on Windows Azure with maximal control and minimal effort for deployment and configuration.

Read Workflows, Services, and Models by David Chappell to see how Dublin relates to Oslo.

A new Version of WF and WCF?

WCF and WF were model-driven right from the beginning, but in the next versions the source for the models that drive Workflows and Services might come from Oslo.

MService is a textual DSL that combines service configuration, implementation and workflow definition into one resource.

What Oslo definitely is

A new Modeling Language Family

Yes, it’s definitely about a new modeling language family “M”, consisting of three core languages. These languages do all have similar Syntax and a shared type system.

  • MSchema
    Defines schemas for data instances. Quite comparable to XSD and DTD.
  • MGraph
    JSON-like format for capturing concrete data instances.
  • MGrammar
    Defines grammars for textual DSLs. Could also be looked at as a Unicode-to-MGraph-tranformation language.

There are other languages planned for some horizontal domains as Database, Services and Web. But here you can even put some more “Pre”s before the “Alpha”.

A Language Workbench for textual DSLs!

Well, I’ll just copy Martin on that.

At some point I really need to rethink what I consider the defining elements of a Language Workbench to be. For the moment let’s just say that Xtext and Oslo feel like Language Workbenches and until I revisit the definition I’ll treat them as such.

Martin Fowler Bliki: Oslo

A new Storage Repository!?

Oslo Repository is a tool and a framework that allows storing models into SQL Server.  I’m still quite torn on this idea.

  • Design-time story: Many tool vendors tried backing repositories supporting simultaneous changes. But sharing them in files is just easier. If it was on the web – ok, then we had to talk about security and stuff – But as it is tied to SQL Server 2008, it looses a lot of my attention.
  • Runtime story: Having models in a database at runtime at least seams more natural in my opinion. What then to store there is another thing to figure out. Is it meant to store operational data or configurations and application definitions? That’s what is left to the customer to decide.

The repository compiler (mx.exe) generates T-SQL code out of your models, while it supports two modes:

  • Plain T-SQL: Mapps your explicit MSchema definitions or implicitely “guessed” schemas from MGraph data to data tables.
  • Repository SQL: A Repository is a database pre-populated with tons of schemas describing the “Microsoft IT world”. It also supports some core services, as are:
    • Deployment: Import and Export from and to M + Webservice Deployment to Dublin
    • Security: Tables hidden behind views, claims-based security
    • Catalog: Keeps the semantics you have in your MSchema as not everything maps directly to T-SQL.
    • Versioning: Sadly not instance data versioning. But you got full SQL Server 2008 capabilities including SSIS, Change Tracking, Replication, … + Due to the separation of views and tables you can support backward-compatible schema evolution.

Oslo does not come with a own data-access technology stack. It rather gives you a generator for EF-Models.

A Graphical Modeling Toolkit!

Yes. Quadrant lets you interact with models graphically. It’s highly generic, customizable and it looks great.

But as I’ve understand, Quadrant only works on models stored in the Repository, hence SQL Server. Really interested to see how this works together with your textual definitions you might rather store in Version Control.

Release Dates, Packaging and Pricing

From Microsoft “Oslo” Frequently Asked Questions

Q: What is the timeline for shipping “Oslo”?

A:  We are not disclosing the release schedule at this time. We are committed to releasing regular Community Technology Previews (CTPs) after PDC and will engage with the developer community on an on-going basis. The Oslo Development Center (http://msdn.microsoft.com/oslo) will also be the place to learn about the latest Oslo-related downloads.

Q: Is “Oslo” shipping with the rest of the Visual Studio 2010 product line?

A: We are not currently disclosing schedules or packaging.