Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News JetBrains Meta Programming System Supports Language Oriented Programming and DSLs

JetBrains Meta Programming System Supports Language Oriented Programming and DSLs

Leia em Português

This item in japanese

Meta Programming System (MPS), a new Language Oriented Programming tool from JetBrains, allows the developers to extend programming languages as well as create Domain Specific Languages (DSLs) for enterprise applications. JetBrains development team recently announced the release of beta version of MPS software.

MPS provides a software development environment to create new custom languages, extend existing languages, and use them to develop domain-oriented applications. It can also be used to define language typesystems, constraints and specialized editors to produce new languages. MPS maintains the code in an Abstract Syntax Tree (AST), which consists of nodes with properties, children and references, and fully describes the program code. In creating a new language, the developers define the rules for code editing and rendering. They can also specify the language type-system elements. This allows MPS to verify program code on the fly to make programming with the new language less error-prone. MPS also uses a generative approach: languages are described on a higher level, and MPS generates compilable code in other languages including Java, XML, HTML and JavaScript. To create a new language using MPS, you need to extend BaseLanguage. MPS also comes with several helpful extensions to BaseLanguage for working with strings, collections, dates, regular expressions, etc.

Language Oriented Programming (LOP) is a new style of programming where the developers can create specialized languages just as they can create classes or methods in a conventional language, use them to develop software, and extend them when and how required. Martin Fowler blogged about Language Workbenches to use as IDE tooling to make language oriented programming a viable approach. He also wrote about MPS as a language workbench tool.

MPS is also useful in creating DSLs where you can define custom language editors and other constraints for any new language. Domain experts who are not familiar with traditional programming can work in MPS with their domain-specific languages using domain-specific terminology.

MPS software is free for all users and a major part of its code will be open-sourced under Apache 2.0 license. It started in 2003 as a research project and JetBrains developers have been using it for developing some of their new products. The team is targeting for Beta 2 Release of MPS next month and version 1.0 release some time in the first quarter in 2009. JetBrains also released new versions of their IDE tool IntelliJ IDEA (version 8.0) and the team collaboration tool TeamCity (version 4.0) products back in November. More concepts on how MPS works and the new beta version download are available on their web site. There are also a user guide, tutorial and a blog site to learn more about the tool.

InfoQ spoke with Konstantin Solomatov, core MPS developer at JetBrains about the MPS software features and the future road map of the project. InfoQ asked how MPS compares with other modeling and code generation tools like Eclipse Modeling Framework (EMF) or openArchitectureWare (oAW).

MPS is based on concepts similar to EMF and oAW. All three technologies allow creating a meta-model, describing its editor and other aspects such as completion, model transformation (which we call 'generator' in MPS), etc. EMF models are usually edited with a graphical editor where you create a diagram representing entities using the box-and-line style. There are domains where this approach works nicely, for example, ER diagrams. However we do not think it is good for creating any relatively mature software.

The most interesting part of oAW is xText framework that allows defining textual DSLs that are parsed into EMF model. But this way of creating languages has its limitations too. If you want to combine languages inside of a file, you have to be sure that the resulting grammar isn't ambiguous, i.e. that for each input there is only one way to interpret it. It's hardly possible in text based languages. For example, two different vendors might want to create a language adding support for monetary values into Java. Both of them add a new Money type to the language. Consider a code that uses both of the new types. When we parse a file like that, containing a variable of the Money type we can't decide whether this type is from the first or the second language.

MPS, in its turn, stores its models as abstract syntax trees and allows editing them directly. In MPS, code looks like text and in many aspects it behaves like text. But since we never convert code to text and back, we don't have to worry about grammar ambiguities.

MPS also seems to allow composing language grammars. How does this feature compare to similar features provided in tools like Oslo and OMeta?

Since MPS isn't text based, it doesn't have any text-based grammar. You define a language by defining the structure of its abstract syntax tree, its abstract grammar. Since we don't have text-based grammar, there are no language compatibility issues, as they are compatible by definition. With Oslo and Ometa both being text based, there are problems similar to xText.

Comparing with Oslo and Ometa that only allow defining parsers for languages, MPS provides additional features such as editor, constraints, type-system, data flow analysis and generator.

What are the new products the JetBrains development team is using MPS as the modeling and development tool?

One of the new products is JetBrains issue tracker, code-named "Charisma", which is due for public release in Q1 2009. It is completely written in MPS. Charisma is already used as an issue tracker for MPS itself, for TeamCity and other products. While creating Charisma we developed a full stack of web development languages that serve as MPS' counterpart of J2EE.

What is the future road map and the new features for MPS project?

The main goal of the Beta is to gather feedback from MPS users and decide on the future roadmap. We have a plan for 1.0 but there are no big changes and new features planned till 1.0. We will publish a more distant roadmap once we release MPS 1.0 in Q1 2009. There you can expect debugger support, and a couple of new languages such as a language for defining UI.

Rate this Article