Archive for February, 2009

Tuples Support in the MPS Base Language

Thursday, February 26th, 2009

Many functional and dynamic languages have “tuples” in their syntax. Tuple is a sequence of a fixed length. For example, pair, triple and quadruple are tuples. They are very useful when you have algorithms operating on entities which have two, three or more parts and you don’t want to create devoted classes for them, or if you want to return multiple instances from a method.

Let’s take a closer look at how tuples are implemented in MPS.

We have a tuple type. Here is a pair of String and int:


We have a special syntax for tuple construction: we added a new type of literal to the base language:

Each element of a tuple has a name by which it can be accessed:


Tuples are immutable, so you can only create new tuples but can’t change the existing ones. If two tuples contain same element types but different names they are compatible. I.e. you can write:

It took us only about half a day to implement such a cool features in MPS, so it isn’t really hard to do. This feature is going to be available in MPS Beta 2.

MPS Beta 2 should be available next week. Check back at MPS web site or at this blog for the announcement.

Posted by Konstantin Solomatov, Lead MPS developer

MPS at DSL Workshop by SAP AG

Wednesday, February 18th, 2009

On Feb 12-13, I was taking part in DSL Workshop by SAP in Walldorf, Germany. Walldorf is a small town 150km away from Frankfurt am Main, with population of about 15000, mostly SAP employees. I spoke on MPS there.

On the first day, presentations on different DSL technologies were scheduled, my speech on MPS among them. I had initially planned to speak for about 20 minutes but it has taken about an hour. People were asking a lot of questions about MPS, especially about our editor. They were surprised when they saw how similar our editor is to conventional text editors even though we edit syntax tree directly. The ability to create and extend languages which is a unique feature of MPS has also drawn a lot of attention. Overall, I believe it was a really successful appearance :-)

Of course, there were lots of other presentations, most notably those on Stratego/XT, WebDSL, SAP DSL Infrastructure, XText, Mod4j (which isn’t available yet) and other interesting stuff. Stratego/XT is a platform for text-based languages developed by Eelco Visser, among others. WebDSL is a set of DSLs for web application development. SAP DSL infrastructure is developed by SAP in order to create DSLs for use in their own products. XText is another product that supports development of text-based languages. In addition to language definition, it provides an Eclipse-based editor and integrates with Eclipse-based modeling framework. Mod4j is a set of tools that simplify JEE development using DSLs. On the second day, we discussed architectural options and tradeoffs that should be decided upon when designing a new DSL infrastructure.

I would definitely like to thank SAP AG for arranging this excellent workshop and making it possible for me to make an appearance. Special thanks go to individual participants of the workshop: Axel Uhl (SAP), Bernd Kold (SAP), Thomas Goldschmidt (SAP), Markus Voelter (Itemis), Lennart Kats (TU Delft), Eelco Visser (TU Delft), and Jos Warmer (Ordina).

You can take a look at pictures that I’ve taken during this workshop.

Posted by Konstantin Solomatov, Lead MPS developer