Translation vs export

I got a question about my recent post on Good and bad ways of exporting DSL models. Adrián Szegedi messaged me on the MPS Slack and wanted to clarify why I don’t recommend using the MPS generator to export models. He said it worked for him when he built a generator to export the MPS structure model to a set of Java classes. His generator converted this concept: concept VeryEmpty extends BaseConcept implements IEmpty instance can be root: false alias: <no alias> short description: <no short description> properties: first : string second : integer third : boolean fourth : SomeEnum children: childo : VeryEmpty[0....

Use empty text for empty cells

MPS lets you customize the empty (placeholder) cell for any optional link, that is the cell that shows some gray text like no propertyValue or simply << ... >>. You generally want the custom placeholder to look just like the default one, except you may need to set a custom menu or change the default text to something more user-friendly. So you create a constant cell and specify its text. But by default this text is drawn in bold black and it looks out of place....

Advanced editors: splitting child collection in editor

I recently had to model a data warehouse star schema. The central table of a data warehouse is called a fact table. This table has two kinds of columns: dimensions and facts. If I were modelling it from scratch, I could have used two separate child links for the different columns. In pseudocode: concept FactTable children: - dimensions: DimensionColumn[0..n] - facts: FactColumn[0..n] However, in my case I had to make sure the FactTable is a KernelF record so it had to implement the IRecordDeclaration interface concept:...

Get feedback from users with generic comments

As we have seen when discussing Typesystem vs constraints and as Kolja Dummann says in his MPS Community Meetup presentation, it is often useful to let users write invalid code. This gives users an easy to use place to leave feedback: “Hey, the DSL tells me that ‘foo’ is invalid here, but I actually should be able to write that.” Sometimes it makes sense for a user to leave a textual comment at some place, say “I want to be able to write ‘foo bar baz’ here but the IDE doesn’t let me”....

Dot expressions: hiding inapplicable operands

In a recent post I suggested that you prefer the typesystem aspect over constraints when implementing the “business rules” of your language. The reason was that the typesystem aspect is less restrictive and therefore lets the language users express themselves better and provides opportunities for guidance. Today I want to cover one particular case where the best practice is the opposite: to prevent the user from seeing invalid choices. The case is a so called “dot expression”, an expression such as variable....

My DSL development process

Is it possible to have a process for developing new DSLs? In this article I’m going to describe my rather informal personal process, and I’d be interested to learn how you approach DSL development. My process starts with talking to the customer about the new feature they want built. I’ll ask probing questions to figure out if maybe we shouldn’t be doing the feature just yet. Perhaps a library that we use, such as mbeddr....

How do I generate language X from MPS?

There’s a page on MPS Confluence listing available “base languages” (languages that you could generate your DSL models into). Java, XML, Ant, JSON, R, JavaScript, and others are supported. But don’t fall into a trap thinking you need to have a language implemented in MPS to be able to generate files in that language! If you want to generate a complex language for which there exists no implementation in MPS, say Rust or Ruby, I recommend that you first use the com....

Good and bad ways of exporting DSL models

If you’re looking to export your data from MPS for use in a different application there are two approaches I would recommend: The simplest way: NodeSerializer from MPS-extensions, as described in yesterday’s post. This lets you quickly export your data in a rather nice XML structure. The most flexible approach: writing a custom exporter by using the MPS Open API to recursively traverse a node tree. You can output any format you want (XML, JSON, YAML, etc....

The simplest way to export your data from MPS

I’ve seen a few questions lately asking whether one can access the data/code one has in MPS from outside of MPS. The simplest way to make MPS models available to external tools is to export a root node or an entire model in XML format using NodeSerializer from the MPS-extensions project. Here is how you can try out NodeSerializer on your model: If you are not using MPS-extensions or mbeddr platform in your project install the de....

Who is MPS for?

MPS was originally created for developers by developers, with the dream to raise the level of abstraction and thus write new software faster. This didn’t quite work out, though. The developers already have great tools to work with text files, and they have had Lisp since the 60s, Racket since the 90s, and Clojure since the 00s. Not to mention Yacc, Bison, and ANTLR. So if not for developers, who is it for?...

Want to receive MPS tips directly in your inbox? Leave your e-mail address below.