This is in regards to Meta Programming System or MPS by JetBrains. Thus far, from my efforts to learn how to use MPS, I have only learned its basic purpose and that it is very complex.

Is MPS worth learning?

Is there anyone who already effectively uses MPS to create their own languages and editors for those languages and uses these created editors as their primary way of programming? If so, what types of programs have they made with this?

3 Answers
3

I found the metaprogramming facilities in Boo and Ruby to be quite useful for building domain specific languages. Ayende Rahien's Domain Specific Languages in Boo was helpful when I was building a DSL for test automation. It may not directly apply to JetBrain's system, but it should be helpful for understanding the potential of a flexible language infrastructure.

Java itself has a fair amount of boilerplate that's required in order to get anything useful done. DSLs and code generation tools can help isolate some of that cruft, if they are well-designed. I don't know Jetbrains tool well enough to tell you if it's worth learning, but understanding how to build DSLs and understanding metaprogramming in general is totally worth it. It looks like JetBrains' product occupies a niche similar to the Microsoft Visualization and Modeling SDK, but I found the Microsoft tool a bit too frustrating in my limited use of it, mostly due to the emphasis on visual tools. Since the MPS seems to do a pretty good job on focusing on the text editing experience for the generated DSL, that might be enough to convince me to dig into it.

There's a certain subculture of developers who are cynical about any kind of meta-programming, and another subculture that is skeptical of any language X where X is not the language they are used to. Sufficiently old-school programmers may recall the 4GL movement that turned out, like many over-hyped endeavors, not to be all the vendors promised; some vendors claimed their language would let businesspeople who understand their domain write code and minimize the need for lower-level programmers. That rarely worked out.

So you may have some organizational resistance to using such tools, but like any tool, used effectively, it can make your team more effective and efficient.

The downside is that, unless you're already experienced doing so, building a DSL may still take you more time than building similar business logic the way you always have: in the clunky constructs of your usual language. The payoff, over time, is worth it, in my opinion. If you've worked with a system that uses metaprogramming effectively, like Rails in Ruby, you'll quickly understand how DSLs can pay off. If you've used something like Boo to build a DSL by altering the compiler pipeline (less painful than it sounds, at least in Boo), you quickly enjoy the power better ways of expressing your problems.

But unless you've got a team that is already in their element using such tools, you'll need to start slowly. Maybe the business rules for pricing a contract or product would benefit from a terse, easy-to-read language that allowed you to rapidly respond to changes in offerings, discounting schemes, etc. Or you could find the most tedious, repetitive coding task you have and explore whether a DSL that simplifies that task can help you.

While not on Java, I've been wanting to make my own meta-programming for a while on .NET (Irony(link 1) is a cool thing to look at), I think of using the M modelling language(link 2) once I learn it too.

I'd post this as a comment, but thanks to this rant I can't, so I'll try and throw a 2¢ while I'm at it).

If you think about it, a language is a tool to tell the computer what to do. Some languages are more specific than others, and let you express what you want in a much more concise way than others (for a particular subject). Others try to be broad and provide a consistent baseline from where to build upon.

But these restricted, specific, and simplistic "Domain Specific Languages(link 3)" are great for the occasional cases where what you want is specific. In those cases, they save you a lot of typing and possible mistakes.

For instance, think about how much time you'd waste if you had to use an Object-Oriented "SQL API" for Java (and how verbose that would be) instead of using SQL queries that are so short and convey the message so clearly.

I'd love if more domain-specific languages were in use. I don't like XAML much (altough it is better than how UIs are coded in Winforms), but I see it as a step in the good direction. I'd like to, in a middle-term future, design DSLs for certain common tasks I do frequently, such as a simplified HTML annotation language that outputs hacked-for-IE code without me having to do the same things over and over (or maybe I don't do this, but that's not the point).

tl;dr:

I never used MPS, but I think if you're a Java guy by all means check it out, Java gets brains rusted after a while IMHO. How to learn it? Find something you'd like a language for (something repetitive and boring), and make a language for it! If it's useless, at least you'll have a new tool on the belt.