How Does MPS Work?
Dialects and domain-specific lingo frequently arises to help people communicate effectively. MPS brings the same flexibility into the world of programming languages. Unlike traditional programming languages with strict syntax and semantics, MPS allows languages to be created, altered or extended by their users.
The core problem of extending languages lies mainly in the parsers. Parsers tie code persistent representation with the visual notation and they cannot be combined with other parsers easily, which prevents language modularization.
This naturally leads to the idea of non-textual presentation of program code. A major benefit of this approach is that it eliminates the need for parsing. Our solution is to always have code maintained in an Abstract Syntax Tree (AST), which consists of nodes with properties, children, and references, and fully describes the program code.
The task of the MPS editor is then to visualize the AST in some user-friendly way and provide means for effective editing. For classical textual languages, the editor should give the user the illusion of editing text in a text-like manner, for graphical notations, on the other hand, the editor should take on the habits of a well-behaving diagramming editor.
When creating a language, you define the rules for code editing and rendering. You can also specify the language type-system and constraints. This allows MPS to check program code on the fly, and thus makes programming with the new language easy and less error-prone.
With MPS you can define custom editors for any new language and make using these DSLs simpler. Even domain experts, who are not familiar with traditional programming, can easily work in MPS with domain-specific languages designed around their domain-specific terminology.
A projectional editor allows the user to edit the Abstract syntax tree (AST) representation of code in an efficient way. It can mimic the behavior of a textual editor for textual notations, a diagram editor for graphical languages, tabular editor for editing tables and so on. The user interacts with the code through some intuitive on the screen visuals and can even switch between multiple displays of the same code.Watch video tutorial
JetBrains is well known for their high-performance IDEs and development tools, and MPS is no exception.
MPS is a powerful IDE with all you need to get full advantage of the DSLs. Some of the features included are: Code completion, navigation, refactoring, error checking, quick fixes, debugging of DSLs, language versioning with automatic migrations and integration with mainstream version control systems.Watch video tutorial
Bridging the semantic gap between the business domain on one side and the implementation domain on the other is handled by the MPS generator.
While a domain-specific language formalizes the business knowledge of the domain experts, the generator encapsulates the implementation of that knowledge in a given technology. The generator preserves the expertise of the most senior software developers in a reusable form and lets others benefit from it.
The clear separation of the business knowledge, contained in the language, and the implementation knowledge, held in the generator, allows users to target multiple platforms at the same time by using multiple generators for the same language. Users can also save on efforts when switching the target implementation technology, since only the generator needs to be changed. The business knowledge contained in the existing domain-specific models can remain intact.
MPS for Creating DSLs and Language Extensions